Shellies Discovery Script

New version: 0.9.4

Changelog:

  • add temperature and overtemperature sensors to Shelly Plug S

Anyone has old Shelly Plug (without S)? This plug send overtemperature and temperature topics?

Hi,

I’ve configured MQTT on ShellyHT and I’ve installed this nice script and now I’ve my ShellyH&T sensor integration.
I know that the device is in sleep mode most of the time and it updates only when there is a significant change in temperature or humidity.
The problem is that MQTT shelly sensors are updated only few times a day, and usually they don’t keep up with the shelly device.
I checked MQTT log and it looks like ShellyHT device sends data correctly, or at least it connects to MQTT broker but data are not updated.
For example, (at the moment) the last values in HA are from 04:00AM, but from the app I can see that the values have already updated many times and the current real values are different from HA sensors.
Does anybody has the same problem, or knows how to solve it?
I configured MQTT Shelly with retain true.

This is my log:

1561006252: New connection from 192.168.X.XXX on port 1883.
[INFO] found mosquito on local database
1561006255: New client connected from 192.168.X.XXX as shellyht-XXXXXX (c1, k60, u'XXXXXX').
1561006345: Client shellyht-XXXXXX has exceeded timeout, disconnecting.
1561006345: Socket error on client shellyht-XXXXXX, disconnecting.
1561007612: Saving in-memory database to /data/mosquitto.db.
1561008515: New connection from 192.168.X.XXX on port 1883.
[INFO] found XXXXXX on local database
1561008517: New client connected from 192.168.X.XXX as shellyht-XXXXXX (c1, k60, u'XXXXXX').
1561008608: Client shellyht-XXXXXX has exceeded timeout, disconnecting.
1561008608: Socket error on client shellyht-XXXXXX, disconnecting.
1561009413: Saving in-memory database to /data/mosquitto.db.
1561009982: New connection from 192.168.X.XXX on port 1883.
[INFO] found XXXXXX on local database
1561009984: New client connected from 192.168.X.XXX as shellyht-XXXXXX (c1, k60, u'XXXXXX').
1561010075: Client shellyht-XXXXXX has exceeded timeout, disconnecting.
1561010075: Socket error on client shellyht-XXXXXX, disconnecting.
1561010430: New connection from 192.168.X.XXX on port 1883.
[INFO] found XXXXXX on local database
1561010432: New client connected from 192.168.X.XXX as shellyht-XXXXXX (c1, k60, u'XXXXXX').
1561010523: Client shellyht-XXXXXX has exceeded timeout, disconnecting.
1561010523: Socket error on client shellyht-XXXXXX, disconnecting.

Thanks Marco

EDIT: I found the problem, I had MQTT and cloud enabled at the same time, so MQTT didn’t work properly. Now that I disabled cloud everything works fine.

I configured my first Shelly H&T two days ago. My settings:

temperature threshold: 1
humidity threshold: 3
sleep mode period: 1

and temperature/humidity sensors are updated quite often:


I use only MQTT (no cloud).

Thanks @Bieniu

I had a configuration problem, between MQTT and cloud, now it is working fine.

To everyone using the script.
On the Shelly group it is a proposal to change the topic announce from global to individual for each device. This will break my script and I’m not sure if I will be able to change it enough to work at all. I’m asking you to take part in that discussion so that the developers of Shelly know that there are people who don’t like this change.

@Bieniu

Could you please add the “input” stream to auto discovery? In Shelly settings it is possible to detach the relay from the switch and using “input” you are able to see the state of the switch. This allows a lot of additional possibilities with home automation.

Input and longpush are on my to-do list.

1 Like

New version: 0.9.5

Changelog:

  • add binary_sensor for input topic (Shelly1, Shelly1 PM, Shelly2, Shelly2.5)

thank you for this fast integration!

I’d like to manipulate the state of the input in HA so I’ve tried changing it from binary_sensor to a switch adding this in the shellies_discovery automation:
shellyswitch25-7404BF-input-0: ‘switch’

Unfortunately, this did not change anything. What do I have to do to change the sensor to a switch or if it can’t be changed, just change the state of the input sensor within HA?

It’s not possible to change the binary_sensor in the switch. Shellies only allow you to watch the value of input. You can’t change input value directly. To change the input state, you have to change the switch entity state.
Honestly, I don’t understand the idea of ​​a detached switch. Can you explain what exactly you want to achieve?

For my use case I don’t need the detached option. Here is what I want to achieve:

I want a motion sensor to turn on the relay of the shelly which will also be automatically turned off after 30 seconds if there is no longer a motion. I also have a physical switch that can turn on the light if I don’t want the motion sensor to turn off the light after 30 seconds.

For this to work I need an automation that looks for the input value of the shelly.
So after 30 seconds it should see if the input value is “on” and then the motion sensor won’t turn off the switch even if there is no motion.

This would all work, but the problem is that if I turn off the light using Alexa or the shelly button within HA, the input value won’t be affected. This way the switch shows the light is off whereas the input still shows on. It is only possible to change the input value using the actual light switch.

This is why I need to directly change the input value. So I wanted to make an automation that the input goes to “off” as soon as the switch (relay) goes from “on” to “off”. This way it doesn’t matter if I use the actual light switch to turn the light off or use Alexa or the shelly button within HA.

I hope my description isn’t too complicated too understand as it is actually very simple. :slight_smile:

OK, now I understand your problem. It seems to me that topic input informs about the state of the physical switch. It can’t be changed without using this physical switch. Only Shelly developers may change this.

1 Like

New version: 0.9.6

Changelog:

  • add binary_sensor for longpush topic (Shelly1, Shelly1 PM, Shelly2, Shelly2.5)
  • add expire_after flag for battery powered sensors
1 Like

New version: 0.9.7

Changelog:

  • add abbreviation for light template variable names [HA 0.95 required]

Shellies Discovery script is now available in HACS

Just bought myself a few Shellies. Because I already have some ESP8266 I wanted to flash them with ESPHome, before I came across this discovery script.

What are the pros and cons of this script compared to ESPHome?

I don’t use ESPHome with Shellies. Shellies stock firmware is very good in my opinion.

Shellies Discovery Script not showing up in HACS Version: 0.11.1 ??