srk23
(Srk23)
March 2, 2019, 9:41am
1
I am sure I am missing something basic here. I have just moved my Shelly 1 to MQTT and have it working fully. However, every time I restart HA, the Shelly defaults to ‘unavailable’. If I go to the Shelly web interface and reset the device, it becomes available and works as expected.
My HA config:
switch:
- platform: mqtt
name: "Bedroom light"
state_topic: "shellies/shelly1/relay/0"
command_topic: "shellies/shelly1/relay/0/command"
availability_topic: "shellies/shelly1/online"
payload_on: "on"
payload_off: "off"
payload_available: "true"
payload_not_available: "false"
retain: true
In the Shelly MQTT config, I have ‘clean session’ and ‘retain’ checked, and max QOS set to 0 (default).
What am I missing?
H143
(Alex)
March 2, 2019, 1:21pm
2
i had the same isue you have to uncomment "availability_topic: “shellies/shelly1/online”
srk23
(Srk23)
March 2, 2019, 8:29pm
4
Commenting out the availability topic does indeed work. Not ideal - it would be nice to be able to see when the device is offline, but does solve the problem for now.
Tasmoto is an option (I have lots of sonoffs flashed already) but I actually quite like that the shelly device runs stock firmware with no hassle. Plus it is wired in the ceiling rose above the ceiling and would be a pain to flash (I don’t have neutral to my switches)…
eXtatic
(Dominik 🇩🇪)
March 2, 2019, 8:47pm
5
Seems like retain is not working properly. Can you test what the broker sends you when you subscribe to the availability topic?
Snakuzzo
(snakuzzo)
March 11, 2019, 1:25am
6
Have you checked Shelly settings ?
There is a note on the official docs about Will Topic value after upgrade.
Snakuzzo
(snakuzzo)
March 11, 2019, 1:27am
7
Ok…I tried…same issue here…
Snakuzzo
(snakuzzo)
March 11, 2019, 1:53am
8
3 Likes
oriolism
(Oriolism)
March 11, 2019, 1:58am
9
You can set an automation that sends an empty MQTT message when HA becomes available. That way the shelly report its status back to HA.
Automation
- id: Update_Sonoff_Start
alias: 'Update Sonoff at Start'
trigger:
- platform: homeassistant
event: start
action:
- delay: 00:00:30
- service: script.turn_on
entity_id: script.update_sonoff
Script:
update_sonoff:
alias: Update Sonoff at Start
sequence:
- service: mqtt.publish
data:
topic: "cmnd/family/power"
payload: ""
- service: mqtt.publish
data:
topic: "cmnd/sonoff7/power2"
payload: ""
2 Likes
srk23
(Srk23)
March 11, 2019, 12:50pm
10
I’ll give that a try - thanks!
Crhass
March 11, 2019, 1:00pm
11
I have been doing this for a while, works for me.
srk23
(Srk23)
March 11, 2019, 8:46pm
12
I can confirm that the following combination of the two suggestions above works:
- id: '00014'
alias: Shelly sync at HA start
trigger:
- platform: homeassistant
event: start
action:
- delay: 00:00:20
- service: mqtt.publish
data:
topic: shellies/command
payload: announce
Delay works without needing a script.
Thanks all!
6 Likes
Did you use the python script?
srk23
(Srk23)
May 7, 2019, 7:20am
14
No - no script. Just MQTT and the automation above.
Hi @srk23
Where did you get these topics from? I have shelly 1pm what could mine be?
srk23
(Srk23)
May 7, 2019, 8:06am
16
You can find your MQTT topics in the Shelly app, where you configure your MQTT server details etc.
Hi @srk23 all I have is the will topic which is shellies/shelly1pm-60971A/online
Any idea?
srk23
(Srk23)
May 7, 2019, 10:00am
18
So your topics would be:
Availability: shellies/shelly1pm-60971A/relay/0
Command: shellies/shelly1pm-60971A/relay/0/command
Availability: shellies/shelly1pm-60971A/online
bachoo786
(Bachoo786)
May 7, 2019, 10:16am
19
So I have those as my topics but I get the same issue as your OP. It says unavailable i have added the automation as well like you suggested a few posts up but no joy.
To be fair when I reboot HA it would work and if I done another reboot it would say unavailable
bachoo786
(Bachoo786)
May 7, 2019, 10:40am
20
I think I know the problem
The automation needs to contain initial_state: 'on'
so that everytime it HA restarts the automation runs automatically.