MJPVDH
(Martin)
November 5, 2020, 9:29pm
1
Hi I’m a new user of Home Assistant and have been reading forums for weeks now to set up a good system myself.
This works quite well, but I still have one problem with sending a message via a light switch in Lovelace via mqtt.publish to my Sonoff 433Mhz RF Bridge.
With this command in Developer Tools I can switch it on and off. So that works.
Lights ON
topic: “cmnd/tasmota_C2350D/RfRaw”
payload: ‘AAB04E050801540A3200BE04D827EC01020302030203030202030203020302030203030202030302020302030302020303020203030202030203020303020203030203020203030202030203020302030455’
Lights OFF
topic: “cmnd/tasmota_C2350D/RfRaw”
payload: ‘AAB04C0408012C0A6404F6283201000200020002020000020002000200020002020000020200000200020200000202000002020000020002000202000002020002000002000200020002000200020355’
But how to proceed? I completely lost it.
Thank you in advance for your help!
apmillen
(Andy)
November 6, 2020, 9:08am
2
Why not create a template switch which you can then put in your Lovelace
switch:
- platform: template
switches:
light_name:
turn_on:
service: mqtt.publish
data:
topic: “cmnd/tasmota_C2350D/RfRaw”
payload: ‘AAB04E050801540A3200BE04D827EC01020302030203030202030203020302030203030202030302020302030302020303020203030202030203020303020203030203020203030202030203020302030455’
turn_off:
service: mqtt.publish
data:
topic: “cmnd/tasmota_C2350D/RfRaw”
payload: ‘AAB04C0408012C0A6404F6283201000200020002020000020002000200020002020000020200000200020200000202000002020000020002000202000002020002000002000200020002000200020355’
MJPVDH
(Martin)
November 6, 2020, 4:56pm
3
First of all, thank you for your quick help.
I put it in my configuration.yaml, but I get this error.
Error loading /config/configuration.yaml: ‘utf-8’ codec can’t decode byte 0x93 in position 461: invalid start byte
apmillen
(Andy)
November 6, 2020, 7:40pm
4
That wouldn’t be anything to do with that switch template. Take a look here:
The configuration files, including configuration.yaml
must be UTF-8 encoded. If you see error like 'utf-8' codec can't decode byte
, edit the offending configuration and re-save it as UTF-8
MJPVDH
(Martin)
November 6, 2020, 9:34pm
5
With troubleshooting the config has been restored.
Sorry apmillen I could not make the switch with your setting for configuration.yaml.
Then i get the message: Entity not available: switch.mqtt_switch
francisp
(Francis)
November 7, 2020, 6:34am
6
The setup of @apmillen is basicly correct, however, never use ‘fancy’ quotes :
switch:
- platform: template
switches:
your_light_name:
turn_on:
service: mqtt.publish
data:
topic: 'cmnd/tasmota_C2350D/RfRaw'
payload: 'AAB04E050801540A3200BE04D827EC01020302030203030202030203020302030203030202030302020302030302020303020203030202030203020303020203030203020203030202030203020302030455'
turn_off:
service: mqtt.publish
data:
topic: 'cmnd/tasmota_C2350D/RfRaw'
payload: 'AAB04C0408012C0A6404F6283201000200020002020000020002000200020002020000020200000200020200000202000002020000020002000202000002020002000002000200020002000200020355'
and of course you can only have one switch: statement
1 Like
apmillen
(Andy)
November 7, 2020, 6:57am
7
Ahh I missed those damn fancy quotes! Thanks for rectifying!
MJPVDH
(Martin)
November 7, 2020, 9:39pm
8
Thank you all for your help. With this config I indeed have a working light switch in my lovelace interface.
It can control my Sonoff RF Bridge Portically via the MQTT. On and off works, only now the question if I can put multiple switches in it and if I can create automations for these switches.
Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
Text to speech
tts:
platform: google_translate
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sensor: !include sensor.yaml
switch:
platform: template
switches:
light_name:
turn_on:
service: mqtt.publish
data:
topic: “cmnd/tasmota_C2350D/RfRaw”
payload: ‘AA B0 4E 05 08 0154 0A32 00BE 04CE 27EC 010203020302030302020302030203020302030302020303020203020303020203030202030302020302030203030202030302030202030302020302030203020304 55’
turn_off:
service: mqtt.publish
data:
topic: “cmnd/tasmota_C2350D/RfRaw”
payload: ‘AA B0 4C 04 08 012C 0A50 04E2 280A 010002000200020200000200020002000200020200000202000002000202000002020000020200000200020002020000020200020000020002000200020002000203 55’