Hi Juergen,
You may want to use </> icon after you pasted code so it will nicely fit your post and, more importantly, will keep indentation correct. Indentation is very important when coding yaml.
I have only one lock but I guess what you did is correct when you have 2; one bearer and 2 different IDs.
As to understanding how this work, here is what you can do:
o Go to “Developers Tools” | “Template”
o Paste this at the top and see what’s appearing on the right:
{{ state_attr("sensor.nuki", "state") }}
o Then another line with this:
{{ state_attr("sensor.nuki", "state")["doorState"] == 3 }}
o And finally this:
{{ state_attr("sensor.nuki", "state")["batteryCharge"] }}
So you see that the first one is the WebAPI object in json format, which you then “query” with the templating thing to extract “doorstate”, “batteryCharge” etc. As you see, there is no need to use any script to get the battery level.
By the way, for the battery level, just add this to your “sensor:” section:
- platform: template
sensors:
nuki_battery:
friendly_name: 'Nuki battery'
unique_id: nuki_battery
unit_of_measurement: '%'
value_template: '{{ state_attr("sensor.nuki", "state")["batteryCharge"] }}'
icon_template: 'mdi:battery'
Make sur dash caracter “-” is aligned with others.