1.MQTT communication structure diagram
KC868-Server--------
publish message: status of switch (status topic)
Subscription message: turn on / off command (command topic)
home assistant------
publish message: turn on / off command (command topic)
Subscription message: status of switch (status topic)
2.KC868-Server digital output , digital input , analog input config sample code in configuration.yaml
# Example configuration.yaml entry
switch:
- platform: mqtt
name: 'output-1'
unique_id: output-1
state_topic: 'server/ xxxxxxxxxxxxxxxxxxxxxxxx /state'
command_topic: 'server/ xxxxxxxxxxxxxxxxxxxxxxxx /set'
payload_on: '{"relay1":{"on":1}}'
payload_off: '{"relay1":{"on":0}}'
value_template: '{{ value_json.relay1.on }}'
state_on: 1
state_off: 0
binary_sensor:
- platform: mqtt
name: 'input-1'
unique_id: input-1
state_topic: 'server/ xxxxxxxxxxxxxxxxxxxxxxxx /state'
value_template: '{{ value_json.input1.on }}'
payload_on: 1
payload_off: 0
sensor:
- platform: mqtt
name: 'analog-1'
unique_id: analog-1
state_topic: 'server/ xxxxxxxxxxxxxxxxxxxxxxxx /state'
unit_of_measurement: 'v'
value_template: '{{ value_json.analog1.value }} '
Note: xxxxxxxxxxxxxxxxxxxxxxxx is UID of controller, just replace with your device UID. You can find the UID in ethernet setting.
3.KC868-Server 16 channel output, 16 channel digital input, 4 channel analog input all use in configuration.yaml
KC868-Server-home-assistant-config.txt (Size: 8.15 KB / Downloads: 896)