Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with wall switch and HA automation
#1
Hello Guys,

I have KC868 Server connected to HA by mqtt, i can read the entities and works well, in the relay board i connect 5 different lights also i add a wall switch which i connected to relay board and make an automation in HA to read the state of lights.
To connect relay and HA i manually add code to configuration yaml file.

My problem is that i have errors since i add switch code to yaml file. what im doing wrong??
Keep in mind that the automation works but when i press the button it has a delay 3 sec until light on

this is log details

Error parsing value: ‘dict object’ has no attribute ‘sw12’ (value: {“relay1”:{“on”:1},“relay2”:{“on”:1},“relay3”:{“on”:1},“relay4”:{“on”:1},“relay5”:{“on”:0},“relay6”:{“on”:0},“relay7”:{“on”:0},“relay8”:{“on”:0},“relay9”:{“on”:0},“relay10”:{“on”:0},“relay11”:{“on”:0},“relay12”:{“on”:0},“relay13”:{“on”:0},“relay14”:{“on”:0},“relay15”:{“on”:0},“relay16”:{“on”:0},“input1”:{“on”:0},“input2”:{“on”:0},“input3”:{“on”:0},“input4”:{“on”:0},“input5”:{“on”:0},“input6”:{“on”:0},“input7”:{“on”:0},“input8”:{“on”:0},“analog1”:{“value”:0},“analog2”:{“value”:0},“analog3”:{“value”:1},“analog4”:{“value”:1}}, template: {{ value_json.sw12.on }})

Template variable error: ‘dict object’ has no attribute ‘sw12’ when rendering ‘{{ value_json.sw12.on }}’

my code is:

binary_sensor:

name: ‘sw12’
unique_id: sw-12
state_topic: ‘server/xxxxxxxxxxxxxxxxxxxxxxxx/state’
value_template: ‘{{ value_json.sw12.on }}’
payload_on: 1
payload_off: 0
Reply
#2
there are two way for wall switch panel input trigger output:
1: wall switch trigger output directly by hardware, it's fastest. (use "SW trigger output" = "Enable" in your ethernet setting webpage)
2: set "SW trigger output" = "Disable", every time when you release your finger from buttons will send a input MQTT message to home assistant, then make AUTOMATION in home assisstant. this will have a little delay time for trigger.
do you want wall switch control output directly?
Reply
#3
If i enable SW trigger output KC868 Server dont connect with Home Assistant. To make wall switch to work i follow your video https://www.youtube.com/watch?v=Txlvw9CznhA and i use your code in yaml file.
after that i make the automation in the video. is working but i have the errors. I have purchase the this wall switch from you https://www.kincony.com/glass-touch-mome...panel.html

Something is missing from your code please look at it.

code is: 

  - name: 'sw1'
    unique_id: sw-1
    state_topic: 'server/XXXXXXXXXXXXXXX/state'
    value_template: '{{ value_json.sw1.on }}'
    payload_on: 1
    payload_off: 0
Reply
#4
only SW12 have problem? other SW work well?
Reply
#5
all sw have the same problem, this is an example
Reply
#6
SW is a message auto feedback to home assistant when you pressed the key. if you want add INPUT, you should:

binary_sensor:
name: 'input-1'
unique_id: input-1
state_topic: 'server/xxxxxxxxxxxxxxxxxxxxxxxx/state'
value_template: '{{ value_json.input1.on }}'
payload_on: 1
payload_off: 0
Reply
#7
Didn't work.  It needs to add attributes in the code but i dont know what attributes i have to add??? give me an exaple
Reply
#8
I believe i solved it it! take look to the code

- name: 'sw1'
unique_id: sw-1
state_topic: 'server/XXXXXXXXXXXXXXXXXX/state'
value_template: "{{ state_attr('value_json.sw1' , 'on') }}"
payload_on: '1'
payload_off: '0'
Reply
#9
ok, great, thanks share your information.
Reply


Forum Jump:


Users browsing this thread: