weske2000
(Weske2000)
1
Hello
I try add mqtt switch from Domoticz to Home-assistant.
I have temp sensors already working but switches won,t work.
I hope someone here can helping ![:innocent: :innocent:](https://community.home-assistant.io/images/emoji/twitter/innocent.png?v=10)
I have look already with mqtt-explorer data is here:
Off:--------------------------------------------------------------
{
“Battery” : 255,
“LastUpdate” : “2023-06-28 23:40:33”,
“RSSI” : 12,
“description” : “”,
“dtype” : “Light/Switch”,
“hwid” : “8”,
“id” : “0008000D”,
“idx” : 42,
“name” : “HW - lamp kast”,
“nvalue” : 0,
“stype” : “Switch”,
“switchType” : “On/Off”,
“unit” : 13
}
On:------------------------------------------------------------------
{
“Battery” : 255,
“LastUpdate” : “2023-06-28 23:46:11”,
“RSSI” : 12,
“description” : “”,
“dtype” : “Light/Switch”,
“hwid” : “8”,
“id” : “0008000D”,
“idx” : 42,
“name” : “HW - lamp kast”,
“nvalue” : 1,
“stype” : “Switch”,
“switchType” : “On/Off”,
“unit” : 13
}
This what i see in mqtt-explorer
I try publish on HA domoticz/out/42
“nvalue” : 1, “nvalue” : 0, “nvalue” : 2, and more but nothing will work.
Thanks
nickrout
(Nick Rout)
2
Here is how you add a mqtt switch to HA.
weske2000
(Weske2000)
3
Hello good day
Thanks for your help :nickrout
I have add to HA but switch have status: unavailable
Here my Config
mqtt:
sensor:
- state_topic: “domoticz/out/74”
name: “Buiten”
unit_of_measurement: “°C”
device_class: temperature
value_template: “{{ value_json.svalue1 }}”
- state_topic: “domoticz/out/59”
name: “Zolder”
unit_of_measurement: “°C”
device_class: temperature
value_template: “{{ value_json.svalue1 }}”
- state_topic: “domoticz/out/60”
name: “Vloer R2”
unit_of_measurement: “°C”
device_class: temperature
value_template: “{{ value_json.svalue1 }}”
- state_topic: “domoticz/out/61”
name: “Ketel Aanvoer”
unit_of_measurement: “°C”
device_class: temperature
value_template: “{{ value_json.svalue1 }}”
- state_topic: “domoticz/out/62”
name: “Ketel Retour”
unit_of_measurement: “°C”
device_class: temperature
value_template: “{{ value_json.svalue1 }}”
- state_topic: “domoticz/out/65”
name: “Slaap Kamer”
unit_of_measurement: “°C”
device_class: temperature
value_template: “{{ value_json.svalue1 }}”
- state_topic: “domoticz/out/66”
name: “Vloer R3”
unit_of_measurement: “°C”
device_class: temperature
value_template: “{{ value_json.svalue1 }}”
- state_topic: “domoticz/out/67”
name: “Vloer Verdeler”
unit_of_measurement: “°C”
device_class: temperature
value_template: “{{ value_json.svalue1 }}”
- state_topic: “domoticz/out/68”
name: “Vloer R1”
unit_of_measurement: “°C”
device_class: temperature
value_template: “{{ value_json.svalue1 }}”
- state_topic: “domoticz/out/73”
name: “Garage”
unit_of_measurement: “°C”
device_class: temperature
value_template: “{{ value_json.svalue1 }}”
switch:
- command_topic: “domoticz/out/42/set”
- unique_id: HW - lamp kast
name: “HW - lamp kast”
state_topic: “domoticz/out/42”
command_topic: “domoticz/out/42/set”
availability:
- topic: “domoticz/out/42/available”
payload_on: “ON”
payload_off: “OFF”
state_on: “ON”
state_off: “OFF”
optimistic: false
qos: 0
retain: true
Thanks again
nickrout
(Nick Rout)
4
You’ll have to post it properly as yaml - see here:
weske2000
(Weske2000)
7
sorry this was not my intention.
i will try to solve it myself
Thanks
weske2000
(Weske2000)
8
SOLVED !!!
switch:
name: "HW - lamp kast"
object_id: "42"
unique_id: "42"
state_topic: "domoticz/out/42"
command_topic: "domoticz/in"
value_template: "{{ value_json.nvalue }}"
state_on: "1"
state_off: "0"
payload_on: '{"command": "switchlight", "idx": 42 , "switchcmd": "On" }'
payload_off: '{"command": "switchlight", "idx": 42, "switchcmd": "Off" }'
optimistic: false
qos: 0
retain: false
Thanks