Wow, thanks for this one. Im trying for 2 days now and I’m on my way I guess.
Some of my switches are already appearing in HA. I’m trying to understand this automation, can you help me?
First: I figured that some of my not appearing switches need different dtype in this line:
value_template: ‘{{ trigger.payload_json.dtype == “Light/Switch” }}’
My switches are appearing as Lighting 1 or Lighting 2. So I´ve copied the complete automation 2 times more for Lighting 1 and Lighting 2. This way more DZ switches appearing in HA. Now comes the harder part for me. Those Lighting 2 switches are dimmers in fact. I guess that this dimmer is dimmed operated by payload_template “svalue1” See the the complete mqtt messages for off, on dimming and full below.
So I guess the codes needs to be changed from
topic: 'homeassistant/switch/dz_switch_{{ trigger.payload_json.idx }}/state'
payload_template: '{% if trigger.payload_json.**nvalue** == 1 %} On {% else %} Off {% endif %}'
To
topic: 'homeassistant/switch/dz_switch_{{ trigger.payload_json.idx }}/state'
payload_template: '{% if trigger.payload_**json.svalue1** == 1 %} On {% else %} Off {% endif %}'
But what to do with those percentages behind “svalue1”. Can’t figure this out yet.
{
"Battery": 255,
"Level": 100,
"RSSI": 12,
"description": "",
"dtype": "Lighting 2",
"hwid": "1",
"id": "0030407",
"idx": 793,
"name": "koof",
"nvalue": 2,
"stype": "AC",
"svalue1": "15",
"switchType": "Dimmer",
"unit": 1
}
{
"Battery": 255,
"Level": 46,
"RSSI": 12,
"description": "",
"dtype": "Lighting 2",
"hwid": "1",
"id": "0030407",
"idx": 793,
"name": "koof",
"nvalue": 2,
"stype": "AC",
"svalue1": "7",
"switchType": "Dimmer",
"unit": 1
}
{
"Battery": 255,
"Level": 100,
"RSSI": 12,
"description": "",
"dtype": "Lighting 2",
"hwid": "1",
"id": "0030407",
"idx": 793,
"name": "koof",
"nvalue": 1,
"stype": "AC",
"svalue1": "15",
"switchType": "Dimmer",
"unit": 1
}
{
"Battery": 255,
"Level": 86,
"RSSI": 12,
"description": "",
"dtype": "Lighting 2",
"hwid": "1",
"id": "0030407",
"idx": 793,
"name": "koof",
"nvalue": 0,
"stype": "AC",
"svalue1": "15",
"switchType": "Dimmer",
"unit": 1
)
Secondly: I can switch those appeared switches on in HA but after a few seconds the HA switch switches off automatically. When switching on in HA, the lamp goes on, when the switch turns off automatically the lamp stays on. What I also notice is that when quickly switching on and off the DZ switch in HA, the lamp goes on and off. For this part I like to get some pointers. Coming from Domoticz it seems that Home Assistant has a steep learning curve. Thanks in advance for any feedback