Giter Club home page Giter Club logo

shellyteacher4domo's People

Contributors

dearekaelle avatar enesbcs avatar pagocs avatar svde avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

shellyteacher4domo's Issues

Support for Shelly Pro EM-50

Hi, I have the Shelly Pro EM-50 and was wondering if/how I can help make a template available for this Shelly as well. Thanx in advance

Screenshot MQTT explorer:
image

Shelly addon temperature and voltmeter reporting

Hi. I have installed the Shelly addon with 3 ds18b20 sensors and a analog input voltmeter. The addon is attached to my Shellyplus2pm device. From what I can see in docs the addon is not supported yet by the teacher? The input and output relays works perfecly after I upgraded version of the teacher. I can see 2 temperature readings in domoticz attached to the Shelly2PM , but they are not reporting the readings of the ds18b20 sensors. I suspect I have to change some things in the mqtt_templates_gen2 file to get it working ? I can see the right values of the temperature sensors in MQTT explorer. Maybe you can see in my pictures what I need to change to get it working?
Shellytemp
Shelly domo

After upgrade to Domoticz 2024.2 MQTT doesn't work anymore

I updated yesterday to Domoticz 2024.2.
Since yesterday my Shelly devices based on MQTT don't work anymore.
Advise from Domoticz was to report this issue here.

When I press a device (like light button) in Domoticz I get this error:
Domoticz 2024 2_MQTT Error

The logging of Domoticz shows this:
2024-01-16 21:51:21.317 Error: MQTT Auto discovery: Switch not found!? (shellyplug-s-9A3AC6-relay-0/Lamp kast)

Devicelist shows:
Domoticz 2024 2_MQTT Error_device_id

In version 2024.1 there was no issue.
The MQTT broker (Mosquitto) works on my RaspberryPi.
Domoticz can connect to MQTT.
I have restarted Domoticz: No solution
I have restarted the Raspberry: No solution
I have updated the Rpi with all packaged: No solution
I reran Shelly4Teacher: No solution
I disabled and then re-enabled the MQTT hardware: No solution
I checked for new devices in Domoticz: No solution

Any thoughts about this?

Topics on Domoticz forum:
https://www.domoticz.com/forum/viewtopic.php?p=311850#p311850
and
https://www.domoticz.com/forum/viewtopic.php?p=311901#p311901

Shelly EM support

Hi!
First off, thanks for implementing this (and all the other IoT stuff), much appreciated!

I have a Shelly EM here which is not yet supported by the teacher.
I tried copying over the Shelly 1 PM template and renaming to SHEM. This basically makes the relay and overtemperature sensor available, so partial success. But toggling the relay does not work (neither do I see a change in domoticz when I switch in the Shelly's webUI nor the other way round, switching in domoticz does not really switch the relay)

However, I'd (naturally) like to also add power measurement support.

How do these templates get created? What needs to mapped where?

The following is a mosquitto_sub command for all subtopics of this device generated with
mosquitto_sub -h mosquitto_server -t "shellies/shellyem-123456789012/#" -F %J

Error: Message payload is not valid JSON on topic shellies/shellyem-34945473D3B2/relay/0.

{"tst":"2023-03-11T16:43:19.953152+0100","topic":"shellies/shellyem-123456789012/emeter/0/power","qos":0,"retain":0,"payloadlen":6,"payload":611.53}
{"tst":"2023-03-11T16:43:19.953278+0100","topic":"shellies/shellyem-123456789012/emeter/0/reactive_power","qos":0,"retain":0,"payloadlen":6,"payload":382.27}
{"tst":"2023-03-11T16:43:19.953337+0100","topic":"shellies/shellyem-123456789012/emeter/0/voltage","qos":0,"retain":0,"payloadlen":6,"payload":238.85}
{"tst":"2023-03-11T16:43:19.953388+0100","topic":"shellies/shellyem-123456789012/emeter/0/total","qos":0,"retain":0,"payloadlen":6,"payload":1891.9}
{"tst":"2023-03-11T16:43:19.953438+0100","topic":"shellies/shellyem-123456789012/emeter/0/total_returned","qos":0,"retain":0,"payloadlen":3,"payload":0}
{"tst":"2023-03-11T16:43:19.953482+0100","topic":"shellies/shellyem-123456789012/emeter/1/power","qos":0,"retain":0,"payloadlen":4,"payload":0}
{"tst":"2023-03-11T16:43:19.953528+0100","topic":"shellies/shellyem-123456789012/emeter/1/reactive_power","qos":0,"retain":0,"payloadlen":4,"payload":0}
{"tst":"2023-03-11T16:43:19.953576+0100","topic":"shellies/shellyem-123456789012/emeter/1/voltage","qos":0,"retain":0,"payloadlen":6,"payload":238.85}
{"tst":"2023-03-11T16:43:19.953652+0100","topic":"shellies/shellyem-123456789012/emeter/1/total","qos":0,"retain":0,"payloadlen":3,"payload":0}
{"tst":"2023-03-11T16:43:19.953703+0100","topic":"shellies/shellyem-123456789012/emeter/1/total_returned","qos":0,"retain":0,"payloadlen":3,"payload":0}
{"tst":"2023-03-11T16:43:33.775189+0100","topic":"shellies/shellyem-123456789012/emeter/0/energy","qos":0,"retain":0,"payloadlen":3,"payload":612}
{"tst":"2023-03-11T16:43:33.777174+0100","topic":"shellies/shellyem-123456789012/emeter/0/returned_energy","qos":0,"retain":0,"payloadlen":1,"payload":0}
{"tst":"2023-03-11T16:43:33.777264+0100","topic":"shellies/shellyem-123456789012/emeter/1/energy","qos":0,"retain":0,"payloadlen":1,"payload":0}
{"tst":"2023-03-11T16:43:33.777304+0100","topic":"shellies/shellyem-123456789012/emeter/1/returned_energy","qos":0,"retain":0,"payloadlen":1,"payload":0}
Error: Message payload is not valid JSON on topic shellies/shellyem-34945473D3B2/relay/0.

{"tst":"2023-03-11T16:43:49.930766+0100","topic":"shellies/shellyem-123456789012/emeter/0/power","qos":0,"retain":0,"payloadlen":6,"payload":609.46}
{"tst":"2023-03-11T16:43:49.930859+0100","topic":"shellies/shellyem-123456789012/emeter/0/reactive_power","qos":0,"retain":0,"payloadlen":6,"payload":379.26}
{"tst":"2023-03-11T16:43:49.930897+0100","topic":"shellies/shellyem-123456789012/emeter/0/voltage","qos":0,"retain":0,"payloadlen":6,"payload":238.19}
{"tst":"2023-03-11T16:43:49.930929+0100","topic":"shellies/shellyem-123456789012/emeter/0/total","qos":0,"retain":0,"payloadlen":6,"payload":1902.2}
{"tst":"2023-03-11T16:43:49.930981+0100","topic":"shellies/shellyem-123456789012/emeter/0/total_returned","qos":0,"retain":0,"payloadlen":3,"payload":0}
{"tst":"2023-03-11T16:43:49.931023+0100","topic":"shellies/shellyem-123456789012/emeter/1/power","qos":0,"retain":0,"payloadlen":4,"payload":0}
{"tst":"2023-03-11T16:43:49.931058+0100","topic":"shellies/shellyem-123456789012/emeter/1/reactive_power","qos":0,"retain":0,"payloadlen":4,"payload":0}
{"tst":"2023-03-11T16:43:49.931099+0100","topic":"shellies/shellyem-123456789012/emeter/1/voltage","qos":0,"retain":0,"payloadlen":6,"payload":238.19}
{"tst":"2023-03-11T16:43:49.931141+0100","topic":"shellies/shellyem-123456789012/emeter/1/total","qos":0,"retain":0,"payloadlen":3,"payload":0}
{"tst":"2023-03-11T16:43:49.931181+0100","topic":"shellies/shellyem-123456789012/emeter/1/total_returned","qos":0,"retain":0,"payloadlen":3,"payload":0}

Here is a nicer formatted json_pp version of the same:

{
   "payload" : 611.53,
   "payloadlen" : 6,
   "qos" : 0,
   "retain" : 0,
   "topic" : "shellies/shellyem-123456789012/emeter/0/power",
   "tst" : "2023-03-11T16:43:19.953152+0100"
}
{
   "payload" : 382.27,
   "payloadlen" : 6,
   "qos" : 0,
   "retain" : 0,
   "topic" : "shellies/shellyem-123456789012/emeter/0/reactive_power",
   "tst" : "2023-03-11T16:43:19.953278+0100"
}
{
   "payload" : 238.85,
   "payloadlen" : 6,
   "qos" : 0,
   "retain" : 0,
   "topic" : "shellies/shellyem-123456789012/emeter/0/voltage",
   "tst" : "2023-03-11T16:43:19.953337+0100"
}
{
   "payload" : 1891.9,
   "payloadlen" : 6,
   "qos" : 0,
   "retain" : 0,
   "topic" : "shellies/shellyem-123456789012/emeter/0/total",
   "tst" : "2023-03-11T16:43:19.953388+0100"
}
{
   "payload" : 0,
   "payloadlen" : 3,
   "qos" : 0,
   "retain" : 0,
   "topic" : "shellies/shellyem-123456789012/emeter/0/total_returned",
   "tst" : "2023-03-11T16:43:19.953438+0100"
}
{
   "payload" : 0,
   "payloadlen" : 4,
   "qos" : 0,
   "retain" : 0,
   "topic" : "shellies/shellyem-123456789012/emeter/1/power",
   "tst" : "2023-03-11T16:43:19.953482+0100"
}
{
   "payload" : 0,
   "payloadlen" : 4,
   "qos" : 0,
   "retain" : 0,
   "topic" : "shellies/shellyem-123456789012/emeter/1/reactive_power",
   "tst" : "2023-03-11T16:43:19.953528+0100"
}
{
   "payload" : 238.85,
   "payloadlen" : 6,
   "qos" : 0,
   "retain" : 0,
   "topic" : "shellies/shellyem-123456789012/emeter/1/voltage",
   "tst" : "2023-03-11T16:43:19.953576+0100"
}
{
   "payload" : 0,
   "payloadlen" : 3,
   "qos" : 0,
   "retain" : 0,
   "topic" : "shellies/shellyem-123456789012/emeter/1/total",
   "tst" : "2023-03-11T16:43:19.953652+0100"
}
{
   "payload" : 0,
   "payloadlen" : 3,
   "qos" : 0,
   "retain" : 0,
   "topic" : "shellies/shellyem-123456789012/emeter/1/total_returned",
   "tst" : "2023-03-11T16:43:19.953703+0100"
}
{
   "payload" : 612,
   "payloadlen" : 3,
   "qos" : 0,
   "retain" : 0,
   "topic" : "shellies/shellyem-123456789012/emeter/0/energy",
   "tst" : "2023-03-11T16:43:33.775189+0100"
}
{
   "payload" : 0,
   "payloadlen" : 1,
   "qos" : 0,
   "retain" : 0,
   "topic" : "shellies/shellyem-123456789012/emeter/0/returned_energy",
   "tst" : "2023-03-11T16:43:33.777174+0100"
}
{
   "payload" : 0,
   "payloadlen" : 1,
   "qos" : 0,
   "retain" : 0,
   "topic" : "shellies/shellyem-123456789012/emeter/1/energy",
   "tst" : "2023-03-11T16:43:33.777264+0100"
}
{
   "payload" : 0,
   "payloadlen" : 1,
   "qos" : 0,
   "retain" : 0,
   "topic" : "shellies/shellyem-123456789012/emeter/1/returned_energy",
   "tst" : "2023-03-11T16:43:33.777304+0100"
}
{
   "payload" : 609.46,
   "payloadlen" : 6,
   "qos" : 0,
   "retain" : 0,
   "topic" : "shellies/shellyem-123456789012/emeter/0/power",
   "tst" : "2023-03-11T16:43:49.930766+0100"
}
{
   "payload" : 379.26,
   "payloadlen" : 6,
   "qos" : 0,
   "retain" : 0,
   "topic" : "shellies/shellyem-123456789012/emeter/0/reactive_power",
   "tst" : "2023-03-11T16:43:49.930859+0100"
}
{
   "payload" : 238.19,
   "payloadlen" : 6,
   "qos" : 0,
   "retain" : 0,
   "topic" : "shellies/shellyem-123456789012/emeter/0/voltage",
   "tst" : "2023-03-11T16:43:49.930897+0100"
}
{
   "payload" : 1902.2,
   "payloadlen" : 6,
   "qos" : 0,
   "retain" : 0,
   "topic" : "shellies/shellyem-123456789012/emeter/0/total",
   "tst" : "2023-03-11T16:43:49.930929+0100"
}
{
   "payload" : 0,
   "payloadlen" : 3,
   "qos" : 0,
   "retain" : 0,
   "topic" : "shellies/shellyem-123456789012/emeter/0/total_returned",
   "tst" : "2023-03-11T16:43:49.930981+0100"
}
{
   "payload" : 0,
   "payloadlen" : 4,
   "qos" : 0,
   "retain" : 0,
   "topic" : "shellies/shellyem-123456789012/emeter/1/power",
   "tst" : "2023-03-11T16:43:49.931023+0100"
}
{
   "payload" : 0,
   "payloadlen" : 4,
   "qos" : 0,
   "retain" : 0,
   "topic" : "shellies/shellyem-123456789012/emeter/1/reactive_power",
   "tst" : "2023-03-11T16:43:49.931058+0100"
}
{
   "payload" : 238.19,
   "payloadlen" : 6,
   "qos" : 0,
   "retain" : 0,
   "topic" : "shellies/shellyem-123456789012/emeter/1/voltage",
   "tst" : "2023-03-11T16:43:49.931099+0100"
}
{
   "payload" : 0,
   "payloadlen" : 3,
   "qos" : 0,
   "retain" : 0,
   "topic" : "shellies/shellyem-123456789012/emeter/1/total",
   "tst" : "2023-03-11T16:43:49.931141+0100"
}
{
   "payload" : 0,
   "payloadlen" : 3,
   "qos" : 0,
   "retain" : 0,
   "topic" : "shellies/shellyem-123456789012/emeter/1/total_returned",
   "tst" : "2023-03-11T16:43:49.931181+0100"
}

Is flashing tasmoto onto the Shelly a better solution?
Your note "Energy reporting will not be good, until Domoticz AD implements basic math in templates" makes me doubt whether this will really have the benefit I strive for..
Shelly's own app however shows the same total_returned as MQTT, I think that should suffice, if Domoticz just logs these values.

Or is there a certain cause you have explicitly not implemented support for it yet?

Thanks in advance for any help provided!

Request to implement support for ShellyWallDisplay

Great project. However I'm not yet comfortable with adding my own templates.

I just installed a ShellyWallDisplay, with a fully functional MQTT setup. I can see it in MQTT explorer but can't get it to join all the other Shellly devices that I succesfully included in my domoticz thanks to this teacher.

I would love to be able to update the templates so that at least the relay can be controlled through domoticz.

Shelly blinds keep changing state in Domoticz

Hi Alexander,

Don't know where to start but since I think the issue is being caused by MQTT I start my search here.

Since today I stand out that in Domoticz the Shelly Blinds keep changing their state from open to close en from close to open without actually really going up or down. This only happens at the blinds other devices don't show this behaviour.
Any idea what this could be?
I reran Shellyteacher4Domo (updated) Windows version and rebooted all devices but no changes were detected in Domoticz.
Nothing has changed.

I wanted to rerun ShellyTeacher4Domo with my Rpi but after upgrade I get this error:
pi@raspberrypi:~/shellyteacher4domo $ sudo ./run.sh Mosquitto conf found. persistence ENABLED TKInter init failed no display name and no $DISPLAY environment variable Ini file exists /home/pi/shellyteacher4domo/shellyteacher4domo.py:481: DeprecationWarning: Callback API version 1 is deprecated, update to latest version mqttclient1 = MQTTClient(mqttcompatibility) #gen1 Connecting to MQTT server... /home/pi/shellyteacher4domo/shellyteacher4domo.py:497: DeprecationWarning: Callback API version 1 is deprecated, update to latest version mqttclient2 = MQTTClient(mqttcompatibility) #gen2 Connecting to MQTT server... /home/pi/shellyteacher4domo/shellyteacher4domo.py:512: DeprecationWarning: Callback API version 1 is deprecated, update to latest version mqttclient3 = MQTTClientOnlineCheck(mqttcompatibility) #gen2 online Connecting to MQTT server... /home/pi/shellyteacher4domo/shellyteacher4domo.py:524: DeprecationWarning: Callback API version 1 is deprecated, update to latest version mqttclient4 = MQTTClientOnlineCheck(mqttcompatibility) #gen2 online Traceback (most recent call last): File "/home/pi/shellyteacher4domo/shellyteacher4domo.py", line 552, in <module> loopok2 = connect_mqtt() File "/home/pi/shellyteacher4domo/shellyteacher4domo.py", line 525, in connect_mqtt mqttclient4.subscribechannel = settings.data['trigger_topic4'] KeyError: 'trigger_topic4'

Problem with Shelly Pro1 not reporting back it's status to Domoticz

I used shellyteacher4domo to discover my Pro1, and it seems to be added fine to Domoticz.

If I look at the MQTT explorer, I can see its status being updated if I toggle the relay.

However, this status is not displayed/updated in Domoticz the switch stays off. If it's Off, I can switch it On through the Domoticz UI, however, as the status is not updated I can only do this once. I can do it again if I turn it Off trough the web UI.

Here are some topics and their content:

domoticz/switch/shellypro1-30c6f782d324-0/config:

{"name": "shellypro1-30c6f782d324 Relay 0", "cmd_t": "~rpc", "pl_off": "{\"id\":1,\"src\":\"shellypro1-30c6f782d324\",\"method\":\"Switch.Set\",\"params\":{\"id\":0,\"on\":false}}", "pl_on": "{\"id\":1,\"src\":\"shellypro1-30c6f782d324\",\"method\":\"Switch.Set\",\"params\":{\"id\":0,\"on\":true}}", "stat_t": "~status/switch:0", "val_tpl": "{{ value_json.output }}","stat_off": "false","stat_on": "true","avty_t": "~online", "pl_avail": "true", "pl_not_avail": "false", "uniq_id": "shellypro1-30c6f782d324-0", "qos": 0, "device": {"identifiers": ["30C6F782D324-0"],"manufacturer": "Shelly","model": "shellypro1","name": "shellypro1-30c6f782d324-0"}, "~": "shellypro1-30c6f782d324/"}
shellypro1-30c6f782d324/events/rpc:
{"src":"shellypro1-30c6f782d324","dst":"shellypro1-30c6f782d324/events","method":"NotifyStatus","params":{"ts":1693604153.11,"switch:0":{"id":0,"timer_duration":14400.00,"timer_started_at":1693604153.11}}}
shellypro1-30c6f782d324/rpc:

{"id":1,"src":"shellypro1-30c6f782d324","dst":"shellypro1-30c6f782d324","result":{"was_on":true}}

Shelly Teacher in Docker

Hi Alexander, is it possible to install Shelly Teacher in Docker?

I run Domoticz and Mosquitto in Docker.

Thanks for your reaction.

Regards

Shelly EM3 support

Hi, thanks for your work.
Based on the code for the Shelly EM I have written the following to support the Shelly EM-3 which is very similar.

[SHEM-3] # Shelly EM3
topic=%discovery_prefix%/switch/%shelly_id%-0/relay/config
payload={"name": "%shelly_id% Relay 0", "cmd_t": "~relay/0/command", "stat_t": "~relay/0", "pl_off": "off", "pl_on": "on", "avty_t": "online", "pl_avail": "true", "pl_not_avail": "false", "uniq_id": "%shelly_id%-relay-0", "qos": 0, "": "shellies/%shelly_id%/"}
topic=%discovery_prefix%/sensor/%shelly_id%-0/energy/config
payload={"name": "%shelly_id% Energy 0", "stat_t": "~emeter/0/energy", "avty_t": "online", "pl_avail": "true", "pl_not_avail": "false", "frc_upd": "false", "enabled_by_default": false, "uniq_id": "%shelly_id%-energy-0", "qos": 0, "": "shellies/%shelly_id%/", "dev_cla": "energy", "stat_cla": "total_increasing", "unit_of_meas": "Wh", "val_tpl": "{{(value|float/60)|round(2)}}"}
topic=%discovery_prefix%/sensor/%shelly_id%-0/returnedenergy/config
payload={"name": "%shelly_id% Returned Energy 0", "stat_t": "~emeter/0/returned_energy", "avty_t": "online", "pl_avail": "true", "pl_not_avail": "false", "frc_upd": "false", "enabled_by_default": false, "uniq_id": "%shelly_id%-returnedenergy-0", "qos": 0, "": "shellies/%shelly_id%/", "dev_cla": "energy", "stat_cla": "total_increasing", "unit_of_meas": "Wh", "val_tpl": "{{(value|float/60)|round(2)}}"}
topic=%discovery_prefix%/sensor/%shelly_id%-0/power/config
payload={"name": "%shelly_id% Power 0", "stat_t": "~emeter/0/power", "avty_t": "online", "pl_avail": "true", "pl_not_avail": "false", "frc_upd": "false", "enabled_by_default": true, "uniq_id": "%shelly_id%-power-0", "qos": 0, "": "shellies/%shelly_id%/", "dev_cla": "power", "stat_cla": "measurement", "unit_of_meas": "W", "val_tpl": "{{value|float|round(1)}}"}
topic=%discovery_prefix%/sensor/%shelly_id%-0/reactivepower/config
payload={"name": "%shelly_id% Reactive Power 0", "stat_t": "~emeter/0/reactive_power", "avty_t": "online", "pl_avail": "true", "pl_not_avail": "false", "frc_upd": "false", "enabled_by_default": true, "uniq_id": "%shelly_id%-reactivepower-0", "qos": 0, "": "shellies/%shelly_id%/", "dev_cla": "power", "stat_cla": "measurement", "unit_of_meas": "W", "val_tpl": "{{value|float|round(1)}}"}
topic=%discovery_prefix%/sensor/%shelly_id%-0/voltage/config
payload={"name": "%shelly_id% Voltage 0", "stat_t": "emeter/0/voltage", "frc_upd": "false", "enabled_by_default": true, "uniq_id": "%shelly_id%-voltage-0", "qos": 0, "": "shellies/%shelly_id%/", "dev_cla": "voltage", "stat_cla": "measurement", "unit_of_meas": "V", "val_tpl": "{{value|float|round(1)}}", "avty_t": "~online", "pl_avail": "true", "pl_not_avail": "false"}
topic=%discovery_prefix%/sensor/%shelly_id%-0/total/config
payload={"name": "%shelly_id% Total 0", "stat_t": "~emeter/0/total", "avty_t": "online", "pl_avail": "true", "pl_not_avail": "false", "frc_upd": "false", "enabled_by_default": true, "uniq_id": "%shelly_id%-total-0", "qos": 0, "": "shellies/%shelly_id%/", "dev_cla": "energy", "stat_cla": "total_increasing", "unit_of_meas": "Wh", "val_tpl": "{{value|round(2)}}"}
topic=%discovery_prefix%/sensor/%shelly_id%-0/totalreturned/config
payload={"name": "%shelly_id% Total Returned 0", "stat_t": "~emeter/0/total_returned", "avty_t": "online", "pl_avail": "true", "pl_not_avail": "false", "frc_upd": "false", "enabled_by_default": true, "uniq_id": "%shelly_id%-totalreturned-0", "qos": 0, "": "shellies/%shelly_id%/", "dev_cla": "energy", "stat_cla": "total_increasing", "unit_of_meas": "Wh", "val_tpl": "{{value|round(2)}}"}
topic=%discovery_prefix%/sensor/%shelly_id%-1/energy/config
payload={"name": "%shelly_id% Energy 1", "stat_t": "~emeter/1/energy", "avty_t": "online", "pl_avail": "true", "pl_not_avail": "false", "frc_upd": "false", "enabled_by_default": false, "uniq_id": "%shelly_id%-energy-1", "qos": 0, "": "shellies/%shelly_id%/", "dev_cla": "energy", "stat_cla": "total_increasing", "unit_of_meas": "Wh", "val_tpl": "{{(value|float/60)|round(2)}}"}
topic=%discovery_prefix%/sensor/%shelly_id%-1/returnedenergy/config
payload={"name": "%shelly_id% Returned Energy 1", "stat_t": "~emeter/1/returned_energy", "avty_t": "online", "pl_avail": "true", "pl_not_avail": "false", "frc_upd": "false", "enabled_by_default": false, "uniq_id": "%shelly_id%-returnedenergy-1", "qos": 0, "": "shellies/%shelly_id%/", "dev_cla": "energy", "stat_cla": "total_increasing", "unit_of_meas": "Wh", "val_tpl": "{{(value|float/60)|round(2)}}"}
topic=%discovery_prefix%/sensor/%shelly_id%-1/power/config
payload={"name": "%shelly_id% Power 1", "stat_t": "~emeter/1/power", "avty_t": "online", "pl_avail": "true", "pl_not_avail": "false", "frc_upd": "false", "enabled_by_default": true, "uniq_id": "%shelly_id%-power-1", "qos": 0, "": "shellies/%shelly_id%/", "dev_cla": "power", "stat_cla": "measurement", "unit_of_meas": "W", "val_tpl": "{{value|float|round(1)}}"}
topic=%discovery_prefix%/sensor/%shelly_id%-1/reactivepower/config
payload={"name": "%shelly_id% Reactive Power 1", "stat_t": "~emeter/1/reactive_power", "avty_t": "online", "pl_avail": "true", "pl_not_avail": "false", "frc_upd": "false", "enabled_by_default": true, "uniq_id": "%shelly_id%-reactivepower-1", "qos": 0, "": "shellies/%shelly_id%/", "dev_cla": "power", "stat_cla": "measurement", "unit_of_meas": "W", "val_tpl": "{{value|float|round(1)}}"}
topic=%discovery_prefix%/sensor/%shelly_id%-1/voltage/config
payload={"name": "%shelly_id% Voltage 1", "stat_t": "emeter/1/voltage", "frc_upd": "false", "enabled_by_default": true, "uniq_id": "%shelly_id%-voltage-1", "qos": 0, "": "shellies/%shelly_id%/", "dev_cla": "voltage", "stat_cla": "measurement", "unit_of_meas": "V", "val_tpl": "{{value|float|round(1)}}", "avty_t": "~online", "pl_avail": "true", "pl_not_avail": "false"}
topic=%discovery_prefix%/sensor/%shelly_id%-1/total/config
payload={"name": "%shelly_id% Total 1", "stat_t": "~emeter/1/total", "avty_t": "online", "pl_avail": "true", "pl_not_avail": "false", "frc_upd": "false", "enabled_by_default": true, "uniq_id": "%shelly_id%-total-1", "qos": 0, "": "shellies/%shelly_id%/", "dev_cla": "energy", "stat_cla": "total_increasing", "unit_of_meas": "Wh", "val_tpl": "{{value|round(2)}}"}
topic=%discovery_prefix%/sensor/%shelly_id%-1/totalreturned/config
payload={"name": "%shelly_id% Total Returned 1", "stat_t": "~emeter/1/total_returned", "avty_t": "online", "pl_avail": "true", "pl_not_avail": "false", "frc_upd": "false", "enabled_by_default": true, "uniq_id": "%shelly_id%-totalreturned-1", "qos": 0, "": "shellies/%shelly_id%/", "dev_cla": "energy", "stat_cla": "total_increasing", "unit_of_meas": "Wh", "val_tpl": "{{value|round(2)}}"}
topic=%discovery_prefix%/sensor/%shelly_id%-2/energy/config
payload={"name": "%shelly_id% Energy 2", "stat_t": "~emeter/2/energy", "avty_t": "online", "pl_avail": "true", "pl_not_avail": "false", "frc_upd": "false", "enabled_by_default": false, "uniq_id": "%shelly_id%-energy-2", "qos": 0, "": "shellies/%shelly_id%/", "dev_cla": "energy", "stat_cla": "total_increasing", "unit_of_meas": "Wh", "val_tpl": "{{(value|float/60)|round(2)}}"}
topic=%discovery_prefix%/sensor/%shelly_id%-2/returnedenergy/config
payload={"name": "%shelly_id% Returned Energy 2", "stat_t": "~emeter/2/returned_energy", "avty_t": "online", "pl_avail": "true", "pl_not_avail": "false", "frc_upd": "false", "enabled_by_default": false, "uniq_id": "%shelly_id%-returnedenergy-2", "qos": 0, "": "shellies/%shelly_id%/", "dev_cla": "energy", "stat_cla": "total_increasing", "unit_of_meas": "Wh", "val_tpl": "{{(value|float/60)|round(2)}}"}
topic=%discovery_prefix%/sensor/%shelly_id%-2/power/config
payload={"name": "%shelly_id% Power 2", "stat_t": "~emeter/2/power", "avty_t": "online", "pl_avail": "true", "pl_not_avail": "false", "frc_upd": "false", "enabled_by_default": true, "uniq_id": "%shelly_id%-power-2", "qos": 0, "": "shellies/%shelly_id%/", "dev_cla": "power", "stat_cla": "measurement", "unit_of_meas": "W", "val_tpl": "{{value|float|round(1)}}"}
topic=%discovery_prefix%/sensor/%shelly_id%-2/reactivepower/config
payload={"name": "%shelly_id% Reactive Power 2", "stat_t": "~emeter/2/reactive_power", "avty_t": "online", "pl_avail": "true", "pl_not_avail": "false", "frc_upd": "false", "enabled_by_default": true, "uniq_id": "%shelly_id%-reactivepower-2", "qos": 0, "": "shellies/%shelly_id%/", "dev_cla": "power", "stat_cla": "measurement", "unit_of_meas": "W", "val_tpl": "{{value|float|round(1)}}"}
topic=%discovery_prefix%/sensor/%shelly_id%-2/voltage/config
payload={"name": "%shelly_id% Voltage 2", "stat_t": "emeter/2/voltage", "frc_upd": "false", "enabled_by_default": true, "uniq_id": "%shelly_id%-voltage-2", "qos": 0, "": "shellies/%shelly_id%/", "dev_cla": "voltage", "stat_cla": "measurement", "unit_of_meas": "V", "val_tpl": "{{value|float|round(1)}}", "avty_t": "~online", "pl_avail": "true", "pl_not_avail": "false"}
topic=%discovery_prefix%/sensor/%shelly_id%-2/total/config
payload={"name": "%shelly_id% Total 2", "stat_t": "~emeter/2/total", "avty_t": "online", "pl_avail": "true", "pl_not_avail": "false", "frc_upd": "false", "enabled_by_default": true, "uniq_id": "%shelly_id%-total-2", "qos": 0, "": "shellies/%shelly_id%/", "dev_cla": "energy", "stat_cla": "total_increasing", "unit_of_meas": "Wh", "val_tpl": "{{value|round(2)}}"}
topic=%discovery_prefix%/sensor/%shelly_id%-2/totalreturned/config
payload={"name": "%shelly_id% Total Returned 2", "stat_t": "~emeter/2/total_returned", "avty_t": "online", "pl_avail": "true", "pl_not_avail": "false", "frc_upd": "false", "enabled_by_default": true, "uniq_id": "%shelly_id%-totalreturned-2", "qos": 0, "": "shellies/%shelly_id%/", "dev_cla": "energy", "stat_cla": "total_increasing", "unit_of_meas": "Wh", "val_tpl": "{{value|round(2)}}"}

Switch does not work for Shelly Pro 4PM

Hi,
I ran the script and my devices have been added to domoticz. I get the energy, a lot of devices, input and switches.

But when I try to switch a relay, it says "Commutation on", but nothing happens.

In the domoticz log :
2023-09-17 14:53:27.311 Status: User: admin (IP: 192.168.1.4) initiated a switch command (2154/shellypro4pm2-30c6f78400e8 Relay 3/On

Any idea why the switch of the relay does not work ?

Thank for your help.

Incomplete MQTT GEN1 template Shelly Dimmer2

Trying to convert all my shelly devices to ShellyTeacher4Domo.
It seems the GEN1 Template of the Shelly Dimmer2 is incomplete.

Can u add this?

Path: shellies/shellydimmer2-XXX/light/0/status
payload:
{ "ison": false, "source": "input", "has_timer": false, "timer_started": 0, "timer_duration": 0, "timer_remaining": 0, "mode": "white", "brightness": 100, "transition": 0 }

Path: shellies/shellydimmer2-XXX/light/0/power
value

Path: shellies/shellydimmer2-XXX/light/0/energy
value

Path: shellies/shellydimmer2-XXX/temperature
value

Path: shellies/shellydimmer2-XXX/temperature_f
value

Path: shellies/shellydimmer2-XXX/overtemperature
value

Path: shellies/shellydimmer2-XXX/overpower
value

Path: shellies/shellydimmer2-XXX/loaderror
value

Path: shellies/shellydimmer2-XXX/input/0
value

Path: shellies/shellydimmer2-XXX/input/1
value

Path: shellies/shellydimmer2-XXX/online
value

Path: shellies/shellydimmer2-XXX/announce
payload:
{ "id": "shellydimmer2-XXX", "model": "SHDM-2", "mac": "XXX", "ip": "192.168.0.114", "new_fw": false, "fw_ver": "20230510-082920/v1.13.1-gda6f9f2" }

Path: shellies/shellydimmer2-XXX/info
payload:
{ "wifi_sta": { "connected": true, "ssid": "Unifi beneden", "ip": "192.168.0.114", "rssi": -76 }, "cloud": { "enabled": false, "connected": false }, "mqtt": { "connected": true }, "time": "", "unixtime": 0, "serial": 1, "has_update": false, "mac": "XXX", "cfg_changed_cnt": 0, "actions_stats": { "skipped": 0 }, "lights": [ { "ison": false, "source": "input", "has_timer": false, "timer_started": 0, "timer_duration": 0, "timer_remaining": 0, "mode": "white", "brightness": 100, "transition": 0 } ], "meters": [ { "power": 0, "overpower": 0, "is_valid": true, "timestamp": 0, "counters": [ 0, 0, 0 ], "total": 0 } ], "inputs": [ { "input": 0, "event": "", "event_cnt": 0 }, { "input": 0, "event": "", "event_cnt": 0 } ], "tmp": { "tC": 42.14, "tF": 107.85, "is_valid": true }, "calibrated": true, "calib_progress": 0, "calib_status": 0, "calib_running": 0, "wire_mode": 1, "forced_neutral": false, "overtemperature": false, "loaderror": 0, "overpower": false, "debug": 0, "update": { "status": "unknown", "has_update": false, "new_version": "", "old_version": "20230510-082920/v1.13.1-gda6f9f2" }, "ram_total": 49672, "ram_free": 37004, "fs_size": 233681, "fs_free": 116715, "uptime": 3 }

Path: shellies/shellydimmer2-XXX/input_event/0
payload:
{ "event": "", "event_cnt": 0 }

Path: shellies/shellydimmer2-XXX/input_event/1
payload:
{ "event": "", "event_cnt": 0 }

Path: homeassistant/binary_sensor/shellydimmer2-XXX-overtemperature/config
payload:
{ "name": "shellydimmer2-XXX Overtemperature", "stat_t": "~overtemperature", "enabled_by_default": true, "uniq_id": "shellydimmer2-XXX-overtemperature", "qos": 0, "~": "shellies/shellydimmer2-XXX/", "entity_category": "diagnostic", "pl_on": "1", "pl_off": "0", "avty_t": "~online", "pl_avail": "true", "pl_not_avail": "false", "dev_cla": "problem" }

Path: homeassistant/binary_sensor/shellydimmer2-XXX-overload/config
payload:
{ "name": "shellydimmer2-XXX Overload", "stat_t": "~overload", "enabled_by_default": true, "uniq_id": "shellydimmer2-XXX-overload", "qos": 0, "~": "shellies/shellydimmer2-XXX/", "entity_category": "diagnostic", "pl_on": "1", "pl_off": "0", "avty_t": "~online", "pl_avail": "true", "pl_not_avail": "false", "dev_cla": "problem" }

Path: homeassistant/binary_sensor/shellydimmer2-XXX-loaderror/config
payload:
{ "name": "shellydimmer2-XXX Load error", "stat_t": "~loaderror", "enabled_by_default": true, "uniq_id": "shellydimmer2-XXX-loaderror", "qos": 0, "~": "shellies/shellydimmer2-XXX/", "entity_category": "diagnostic", "pl_on": "1", "pl_off": "0", "avty_t": "~online", "pl_avail": "true", "pl_not_avail": "false", "dev_cla": "problem" }

Path: homeassistant/binary_sensor/shellydimmer2-XXX-input-0/config
payload:
{ "name": "shellydimmer2-XXX Input 0", "stat_t": "~input/0", "enabled_by_default": true, "uniq_id": "shellydimmer2-XXX-input-0", "qos": 0, "~": "shellies/shellydimmer2-XXX/", "pl_on": "1", "pl_off": "0", "avty_t": "~online", "pl_avail": "true", "pl_not_avail": "false" }

Path: homeassistant/binary_sensor/shellydimmer2-XXX-input-1/config
payload:
{ "name": "shellydimmer2-XXX Input 1", "stat_t": "~input/1", "enabled_by_default": true, "uniq_id": "shellydimmer2-XXX-input-1", "qos": 0, "~": "shellies/shellydimmer2-XXX/", "pl_on": "1", "pl_off": "0", "avty_t": "~online", "pl_avail": "true", "pl_not_avail": "false" }

Path: homeassistant/binary_sensor/shellydimmer2-XXX-online/config
payload:
{ "name": "shellydimmer2-XXX Online", "stat_t": "~online", "uniq_id": "shellydimmer2-XXX-online", "~": "shellies/shellydimmer2-XXX/", "pl_on": "true", "pl_off": "false" }

Path: homeassistant/sensor/shellydimmer2-XXX/temperature/config
payload:
{ "name": "shellydimmer2-XXX Temperature", "stat_t": "~temperature", "frc_upd": "false", "enabled_by_default": true, "uniq_id": "shellydimmer2-XXX-temperature", "qos": 0, "~": "shellies/shellydimmer2-XXX/", "entity_category": "diagnostic", "dev_cla": "temperature", "stat_cla": "measurement", "unit_of_meas": "°C", "val_tpl": "{%if is_number(value) and -100<value|int<900%}{{value|round(1)}}{%else%}unknown{%endif%}", "avty_t": "~online", "pl_avail": "true", "pl_not_avail": "false", "device": { "identifiers": [ "XXX" ], "manufacturer": "Shelly", "model": "SHDM-2", "name": "shellydimmer2-XXX" } }

Path: homeassistant/sensor/shellydimmer2-XXX-0/power/config
payload:
{ "name": "shellydimmer2-XXX Power 0", "stat_t": "~light/0/power", "avty_t": "~online", "pl_avail": "true", "pl_not_avail": "false", "frc_upd": "false", "enabled_by_default": true, "uniq_id": "shellydimmer2-XXX-light-power-0", "qos": 0, "~": "shellies/shellydimmer2-XXX/", "dev_cla": "power", "stat_cla": "measurement", "unit_of_meas": "W", "val_tpl": "{{value|float|round(1)}}", "device": { "identifiers": [ "XXX" ], "manufacturer": "Shelly", "model": "SHDM-2", "name": "shellydimmer2-XXX" } }

Path: homeassistant/sensor/shellydimmer2-XXX-0/overpower/config
payload:
{ "name": "shellydimmer2-XXX Overpower 0", "stat_t": "~light/0/overpower_value", "avty_t": "~online", "pl_avail": "true", "pl_not_avail": "false", "frc_upd": "false", "enabled_by_default": true, "uniq_id": "shellydimmer2-XXX-light-overpowervalue-0", "qos": 0, "~": "shellies/shellydimmer2-XXX/", "dev_cla": "power", "stat_cla": "measurement", "unit_of_meas": "W", "val_tpl": "{{value|float|round(1)}}", "device": { "identifiers": [ "XXX" ], "manufacturer": "Shelly", "model": "SHDM-2", "name": "shellydimmer2-XXX" } }

Path: homeassistant/sensor/shellydimmer2-XXX-0/energy/config
payload:
{ "name": "shellydimmer2-XXX Energy 0", "stat_t": "~light/0/energy", "avty_t": "~online", "pl_avail": "true", "pl_not_avail": "false", "frc_upd": "false", "enabled_by_default": false, "uniq_id": "shellydimmer2-XXX-light-energy-0", "qos": 0, "~": "shellies/shellydimmer2-XXX/", "dev_cla": "energy", "stat_cla": "total_increasing", "unit_of_meas": "Wh", "val_tpl": "{{(value|float/60)|round(2)}}", "device": { "identifiers": [ "XXX" ], "manufacturer": "Shelly", "model": "SHDM-2", "name": "shellydimmer2-XXX" } }

Path: homeassistant/select/shellydimmer2-XXX/input_event-0/config
payload:
{ "name": "shellydimmer2-XXX Input Event 0", "json_attributes_topic": "~input_event/0", "value_template": "{{value_json.event}}", "cmd_t": "~dummy", "frc_upd": "false", "enabled_by_default": true, "uniq_id": "shellydimmer2-XXX-event-0", "~": "shellies/shellydimmer2-XXX/", "dev_cla": "event", "stat_cla": "selector", "ops": [ "-", "S", "L" ] }

Path: homeassistant/select/shellydimmer2-XXX/input_event-1/config
payload:
{ "name": "shellydimmer2-XXX Input Event 1", "json_attributes_topic": "~input_event/1", "value_template": "{{value_json.event}}", "cmd_t": "~dummy", "frc_upd": "false", "enabled_by_default": true, "uniq_id": "shellydimmer2-XXX-event-1", "~": "shellies/shellydimmer2-XXX/", "dev_cla": "event", "stat_cla": "selector", "ops": [ "-", "S", "L" ] }

Path: homeassistant/select/shellydimmer2-XXX-0/config
payload:
{ "name": "shellydimmer2-XXX Light 0", "cmd_t": "~light/0/set", "stat_t": "~light/0/status", "payload_on": "{\"turn\":\"on\"}", "payload_off": "{\"turn\":\"off\"}", "value_template": "{{value_json.ison}}", "stat_tpl": "{%if value_json.ison==true%}ON{%else%}OFF{%endif%}", "brightness_command_topic": "~light/0/set", "brightness_state_topic": "~light/0/status", "brightness": true, "color_mode": true, "supported_color_modes": [ "brightness" ], "brightness_scale": 100, "bri_val_tpl": "{{value_json.brightness}}", "avty_t": "~online", "pl_avail": "true", "pl_not_avail": "false", "uniq_id": "shellydimmer2-XXX-light-0", "qos": 0, "~": "shellies/shellydimmer2-XXX/" }

Energy reporting

All values reported by the Shellies with Watt-minute will be incorrect on the Domoticz side, until division implemented in the templates.

If you check templates in database, you can see:
"val_tpl": "{{(value|float/60)|round(2)}}"}

Which is needed for conversion to Watthour (or kWh). Until it will be supported in Domoticz, the energy devices will be disabled by default, but can be enabled manually if you wish on the Domoticz device list, as it is added anyway.

Plugsplugs

I use more shellly plugsplugs

I I add a new one then it only works if I make two different MQTT autodiscovery with different prefix names.
Otherwise the behavior of the two plugs are the same. On/Of en also the data energy use.

I aspect that the ID of each plug makes the plug unique in combination with the prefix.

MIgration to paho-mqtt version 2.0 (if you encounter error: TypeError: Client.__init__() missing 1 required positional argument: 'callback_api_version')

Hi,

first of all thanks for your code!

I have installed it on my ubuntu box running python3.10. The preinstall.sh automatically installs the latest version of paho-mqtt (version 2.0) that is incompatible with the current shellyteacher4domo.py. Details can be found in https://eclipse.dev/paho/files/paho.mqtt.python/html/migrations.html).

The easy solution is to change all instances of:
MQTTClient() into MQTTClient(mqtt.CallbackAPIVersion.VERSION1)
and
MQTTClientOnlineCheck() into MQTTClientOnlineCheck(mqtt.CallbackAPIVersion.VERSION1)

in the connect_mqtt() function.

Hope this can be useful to others in my same situation.

Regards,
l.

Problems when trying to run teacher

Hi . Im getting this when trying to run shellyteacherdomo.py
"Traceback (most recent call last):
File "shellyteacher4domo.py", line 79, in
class MQTTClient(mqtt.Client): # Gen1 detailed infos and Gen2 alive
NameError: name 'mqtt' is not defined"
Im not so good with linux so maybe someone can tell me what's wrong?

Add Shelly GAS Addon Manipulator / Valve support

Good day!
I have got a shelly gas sensor with the shelly valve. The valve and its status (Open/Close) is not detected from your plugin.
Can you support this implementation ?

have a nice day

Dimmer2 Light 0 switch type

Testing on one of my dimmer2's, I noticed that a RGB switch device is created, while the device only supports on/off + brightness, in mqtt_templates.txt:

payload={"name": "%shelly_id% Light 0", "cmd_t": "~light/0/set", "stat_t": "~light/0/status","payload_on": "{\"turn\":\"on\"}","payload_off": "{\"turn\":\"off\"}", "value_template": "{{value_json.ison}}","stat_tpl": "{%if value_json.ison==true%}ON{%else%}OFF{%endif%}","brightness_command_topic":"\~light/0/set","brightness_state_topic":"~light/0/status","brightness": true,"color_mode": true,"supported_color_modes": ["onoff","brightness"], "brightness_scale":100, "bri_val_tpl":"{{value_json.brightness}}", "avty_t": "~online", "pl_avail": "true", "pl_not_avail": "false", "uniq_id": "%shelly_id%-light-0", "qos": 0, "~": "shellies/%shelly_id%/"}

I guess shellyteacher4domo is doing this correctly, but Domoticz MQTT Autodiscovery is creating the RGB dimmer device, while a regular (single color) dimmer would be better.

Shelly plus i4 with Tasmota firmware

Hello Alexander Nagy, aka enebcs,

I recently bought a Shelly plus i4 and set up Tasmota here so I could integrate it into domoticz but I see it's not in your script yet, is it possible you could also add the Shelly plus i4 in the Shellyteach4domo you made because I don't see it listed yet.
I also installed MQTT and Tasmoticz.

I hope to hear from you

Thank you in advance,

Regards Arie Heuvelman,
The Netherlands

Shelly 2PM set_position error

Cover device does not have set_position_topic (shellyplus2pm-441793ceb570-roller-0/NEW

The 0% and 100% for open and close are working fine.

Domoticz docker persistent data

Hello.

Sorry I didn't find another issue.

Mine is Domoticz working from a docker, when I make a docker compose down I loose all my MQTT autodiscovery generated from shellyteacher4domo.

I'm new with docker but I know how to mount volumes to make them persistents.

Could you please hepl me to make persistent data after I ran shellyteacher4domo and after I decide to make a docker compose down for Domoticz ?

Thank you in advance for your help.

Jérôme.

Shelly H&T gen3 seen as switch device instead of temperature and humidity device

Please, check image and logs:

CleanShot 2024-05-29 at 22 29 04

on_message::payload::{"id":1,"src":"shellyhtg3-543204538f44","dst":"shellies_discovery","result":{"ble":{"enable":false,"rpc":{"enable":true}},"cloud":{"enable":true,"server":"shelly-57-eu.shelly.cloud:6022/jrpc"},"devicepower:0":{},"ht_ui":{"temperature_unit":"C"},"humidity:0":{"id":0, "name":null, "report_thr":5.0, "offset":0.0},"mqtt":{"enable":true,"server":"10.0.1.110:1883","client_id":"shellyht-terraza","user":"mqtt","ssl_ca":null,"topic_prefix":"shellyht-terraza","rpc_ntf":true,"status_ntf":false,"use_client_cert":false,"enable_rpc":true,"enable_control":true},"sys":{"device":{"name":null,"mac":"543204538F44","fw_id":"20240522-112842/1.3.2-g34c651b","discoverable":true},"location":{"tz":"Europe/Madrid","lat":38.422300,"lon":-0.697100},"debug":{"level":2,"file_level":null,"mqtt":{"enable":false},"websocket":{"enable":false},"udp":{"addr":null}},"ui_data":{},"rpc_udp":{"dst_addr":null,"listen_port":null},"sntp":{"server":"time.google.com"},"cfg_rev":11},"temperature:0":{"id":0, "name":null, "report_thr_C": 0.5, "offset_C": 0.0},"wifi":{"ap":{"ssid":"ShellyHTG3-543204538F44","is_open":true, "enable":false},"sta":{"ssid":"Kawa636r","is_open":false, "enable":true, "ipv4mode":"dhcp","ip":null,"netmask":null,"gw":null,"nameserver":null},"sta1":{"ssid":null,"is_open":true, "enable":false, "ipv4mode":"dhcp","ip":null,"netmask":null,"gw":null,"nameserver":null},"roam":{"rssi_thr":-80,"interval":60}},"ws":{"enable":false,"server":null,"ssl_ca":"ca.pem"}}}

GEN2 device shellyhtg3-543204538f44 shellyht-terraza found

Gen1 Shelly TRV issue

TRV devices reports its state as:

mqtt_path: "shellies/shellytrv-xxx/info"

payload:

{
    "thermostats": [
        {
            "pos": -1,
            "target_t": {
                "enabled": true,
                "value": 24.0,
                "units": "C"
            },
            "tmp": {
                "value": 17.4,
                "units": "C",
                "is_valid": true
            },
            "schedule": false,
            "schedule_profile": 2,
            "boost_minutes": 0
        }
    ],
    "calibrated": false,
    "bat": {
        "value": 90,
        "voltage": 3.127
    },
    "charger": false,
    "ps_mode": 0,
    "dbg_flags": 0
}

Tried to process the above data with the following HA templates:

"temperature_state_template": "{{ value_json.thermostats[0].target_t.value}}"
"current_temperature_template": "{{ value_json.thermostats[0].tmp.value }}"

At least i got these errors from Domoticz log:
Climate device unhandled temperature_state_template
Climate device unhandled current_temperature_template

Dimmer devices does not change state

In case anyone added Shelly Dimmer devices with an old (before Oct. 2023) ShellyTeacher and Dimmer devices does not change its states under latest Domoticz beta, please download a fresh ShellyTeacher, delete Dimmer devices from Domoticz and re-teach them.

It is necessary as configuration object changed in 2023.10.11 and "state_on" and "state_off" property is used to detect current state.

See #26

Shelly Gen1 devices not showing "Online" status

In the first Shelly python Plugin the online status was reported (device_id e.g. "Shelly - shelly1-XXX-online".
In this new version (ShellyTeacher4Domo) this device_id isn't showing up anymore. Is there a reason?
How was this done in the Shelly Python Plugin? When I look at the MQTT Explorer for 1 of my Shelly1 devices I can't find "Online" state like with ShellyPlus2PM and ShellyPro4pm.

Is this somehting which can be fixed/made with ShellyTeacher4Domo?

Dimmer device remote status

However "brightness_state_topic" defined in the templates, it seems that Domoticz AD will not update Dimmer status if changed on the remote side.

Needs sample data and payloads to report upstream.

Gen 1 devices doens't show actual watt in energy device

Hello,

Was using your old plugin for the gen1 devices and this plugin for the gen 2+3 devices, but with the old plugin and a shelly reboot the total counter resets to 0, which shows a big negative drop in all the charts which can't be removed with the shift click option.

So I wanted to try teacher for the gen1 device, made seperate hardware for gen 1 teacher devices. But when receiving data the gen1 devices total counter counts up, but it doesn't receive the actual power.
Naamloos
Device with the 2 after the name is from the new plugin and a dimmer 1, but RGBW2 also has the same problem.

Strage thing, on the gen2 and gen 3 devices it just works as expected:
Naamlooos
This is from a Plus 1PM trough teacher plugin.

What is wrong? and can you help me? So i hope I get rid of the negative spikes!

Issue with MQTT energy value on ShellyPro4PM

Hi Alexander,

Today I discovered with MQTT Explorer that there is an issue with the Topic of homeassistant/sensor/shellypro4pm-XXXX-3/energy/config

the values are:
{ "name": "shellypro4pm-XXXX-Energy 3", "stat_t": "~status/switch:3", "frc_upd": "false", "uniq_id": "shellypro4pm-XXXX-2-energy", "qos": 0, "~": "shellypro4pm-XXXX/", "dev_cla": "energy", "stat_cla": "total_increasing", "unit_of_meas": "Wh", "val_tpl": "{{ value_json['aenergy'].total }}", "device": { "identifiers": [ "XXXX-3" ], "manufacturer": "Shelly", "model": "shellypro4pm", "name": "shellypro4pm-XXXX-3" } }

As you can see the value uniq_id refers to "shellypro4pm-XXXX-2-energy" which of course should be "shellypro4pm-XXXX-3-energy"

At first I thought it was an issue in the MQTT template (Gen2), So I fixed the value from 2 to 3.
After rebooting the shelly device the shellyteacher4domo didn't find the energy 3 device, so I used MQTT Explorer and found out that the issue is on the Shelly MQTT side.

So I created a support ticket for this at Shelly.Cloud company.
(Reaction time is 72 hours)

In advance you already might update the MQTT_Templates_gen2.txt file with this.

teacher4 crashes with Shelly EM

Hi, first, thanks for your great work about shelly and domoticz !
I'm triing to migrate my shellyes from ShellyMQTT to MQTTautoDiscovery, using teacher4. It works fine for ShellyplusHT (gen2) and Shellymotionsensor (gen1), but crashes with my 2 shellyEM.
Here the error message:

GEN1 device 192.168.1.46 SHEM shellyem-daikin found
Traceback (most recent call last):
File "shellyteacher4domo.py", line 620, in
mqttstr = {"topic": fill_template_str(mt[i]['topic'], di),"payload": fill_template_str(mt[i]['payload'], di)}
KeyError: 'topic'
The view in Mqtt-explorer:
shellies/shellyem-daikin/info
{"wifi_sta":{"connected":true,"ssid":"Freebox_THQUBC","ip":"192.168.1.46","rssi":-73},"cloud":{"enabled":false,"connected":false},"mqtt":{"connected":true},"time":"12:23","unixtime":1696501424,"serial":1,"has_update":false,"mac":"F4CFA2E45677","cfg_changed_cnt":0,"actions_stats":{"skipped":0},"relays":[{"ison":false,"has_timer":false,"timer_started":0,"timer_duration":0,"timer_remaining":0,"overpower":false,"is_valid":false,"source":"input"}],"emeters":[{"power":0.00,"reactive":0.00,"pf":0.00,"voltage":0.00,"is_valid":false,"total":834608.6,"total_returned":12.4},{"power":0.00,"reactive":0.00,"pf":0.00,"voltage":0.00,"is_valid":false,"total":333837.1,"total_returned":0.0}],"update":{"status":"unknown","has_update":false,"new_version":"","old_version":"20230913-114150/v1.14.0-gcb84623"},"ram_total":51064,"ram_free":36368,"fs_size":233681,"fs_free":156122,"uptime":2}
image

thank you in advance for your help !

Cannot get Shelly H&T gen 2 online.

Hello developper,

I have a shelly gen 2 h&t sensor (version with screen) and cannot get it online with the teacher en domoticz.
The teacher keeps telling that the device is "Online" (teacher running on rapberry), but it would not recognise and add the device to domoticz.

What to do?

Kind Regards

Some errors running teacher

Hi!

I'm having some errors running the teacher on a pi:

PuTTY X11 proxy: unable to connect to forwarded X server: Network error: Connection refused
PuTTY X11 proxy: unable to connect to forwarded X server: Network error: Connection refused
TKInter init failed couldn't connect to display "localhost:10.0"
Ini file exists
Connecting to MQTT server...
Connecting to MQTT server...
Connecting to MQTT server...
Starting eval loop, waiting Shelly devices to appear on MQTT announce... press CTRL-C to cancel

settings seem to be correct. Although i'm wondering about the different usage of ' , " and no brackets around the port.

data = { }
# -----------------------------------------------
# WARNING: If .ini file exists it will overwrite the default values below!
# -----------------------------------------------
data['mqtt_ip'] = '10.0.0.4' # mqtt server ip
data['mqtt_port'] = 1883        # mqtt server port
data['mqtt_user'] = ""          # mqtt server username
data['mqtt_pass'] = ""          # mqtt server password
data['discovery_prefix'] = 'shellies' # autodiscovery prefix for Domoticz
testrun = False
retain  = True   # if retain is True, config template will be saved onto mqtt broker permanently
gen1    = True  # enable Gen1 device detection
gen2    = True   # enable Gen2 device detection
debug   = False   # print debug messages if True
# -----------------------------------------------
# DO NOT MODIFY LINES BELOW, UNLESS YOU ARE ABSOLUTELY SURE WHAT YOU ARE DOING!
# -----------------------------------------------
data['trigger_topic1'] = "shellies/announce"      #gen1 device detection
data['trigger_topic2'] = "shellies_discovery/rpc" #gen2 device reply
data['trigger_topic3'] = "+/online"               #gen2 device detection
data['gen1_template_file'] = 'mqtt_templates.txt'
data['gen2_template_file'] = 'mqtt_templates_gen2.txt'
# -----------------------------------------------
## SYSTEM VARIABLES, DO NOT TOUCH!
# -----------------------------------------------
shque = []
shjsons = {}
mqttsender = []

Any thoughts?

Can't computed energy Shelly Plus 1 PM

Hi,

Sorry for my english, but i can't computed energy for my shelly plus 1

Screenshot 2023-04-17 at 10 27 19
Screenshot 2023-04-17 at 10 27 26

and this is my Shelly Dimmer and i have the possibility to computed energy
Screenshot 2023-04-17 at 10 28 08

Did you have an idea?
Many Thanks

RGBW device support

The problem

Domoticz MQTT-AD defaultly sends this payload for RGB devices:
{"color":{"b":77,"g":132,"r":255},"state":"ON"}

It also contains a "hack" to send this payloads for Fibaro FGRGBW:
"value": {"red": 255, "green": 132, "blue": 77}}

But none of the above will work with Shelly as it needs such payload to operate:

{ "mode": "color", "turn": "on","red": 0,"green": 0,"blue": 255,"gain": 100,"white": 0}

See Shelly docs: https://shelly-api-docs.shelly.cloud/gen1/#shelly-bulb-rgbw-mqtt

For adding Shelly RGBW device support, Domoticz MQTT-AD has to implement these at least partially:

rgbw_command_topic, rgbw_command_template, rgbw_state_topic, rgbw_value_template

See HA docs: https://www.home-assistant.io/integrations/light.mqtt/

shelly 1 mini (device support)

Hi!

I'm using a shelly 1 mini (gen2), but it seems that it is not supported with shellyteacher.

---ERROR: GEN2 device shelly1mini-xxxxxx shelly1mini-xxxxxxx template not found

Do we expect this device will be supported in the future?

Thank you.

Retain

Hello all,

Currently, I am not quite convinced that this upgrade is better than the previous shelly mqtt. But I definitely want to give it a try!
I have added shelly devices and they work.
In the trainer4domoticz settings.py "retain = true".
And in the mosquitto "persistence true" & "persistence_location /var/lib/mosquitto/" So this should all be fine.

After a reboot, the devices are still available in domoticz, but not functional. I certainly cannot control a switch or get data from my shelly em3 which is crucial for my home heating.

And power failures do happen sometimes and so does a reboot of me raspberyy pi.
What can I do about this.

Switches merged into one

It seems that all my gen2 shelly plus 2pm switches somehow merge into one. Whenever I use domoticz to switch relay 0 of any of my 4 devices, the relay 0 output of the other 3 toggles as well. When operating relay 1, the others change on relay 1 as well. They all have unique device ids and the issue persists even after clearing mosquito.db and the mqtt auto discovery hardware in domoticz. Gen1 and my single relay gen2 devices appear unaffected.

Different subtype temp

Hi Alexander,

Using the MQTT Auto Discovery with ShellyTeacher4Domo, and now migrating from old Shelly python plugin to the MQTT Auto discovery.

Now I noticed that in the old Shelly Python plugin the temp was measured based on subtype "LaCrosse TX3".
In the new MQTT Auto Discovery with ShellyTeacher4Domo I see a device created for temp measurement on subtype "THR128/138,THC138".

different subtype temp

The same I thing I see for the energy devices:
with old shelly Python Plugin I see a device to measure energy based on type "General" with subtype "kWh"
with MQTT auto Discovery woth ShellyTeacher4Domo I see a device to measure energy based on type "General" with subtype "Custom Sensor".

different subtype energy

Why is this? Why are they not the same?
Where is defined what the correct Type and Subtype should be?

Shelly PlusPlugS gen2 power, voltage and energy devices in domoticz

Hi, currently the Shelly PlusPlugS is supported, but only a switch and temp sensor are created.

However, the PlusPlugS supports other quantities as well: power (Watt), energy (kWh) and voltage (Volt).

To add those, and that they are created by Domoticz, I modified the mqtt_templates_gen2.txt file.
Under
[shellyplusplugs][shellyplusplugus][shellyplusplugit][shellypluspluguk] # Shelly Plus Plug

add:
topic=%discovery_prefix%/sensor/%shelly_id%-0/voltage/config payload={"name": "%shelly_id% Voltage 0", "~": "%shelly_topic%/", "stat_t": "~status/switch:0", "frc_upd": "false", "enabled_by_default": true, "uniq_id": "%shelly_id%-0-voltage", "qos": 0, "dev_cla": "voltage", "stat_cla": "measurement", "unit_of_meas": "V", "val_tpl": "{{ value_json.voltage }}", "device": {"identifiers": ["%shelly_mac%-0"],"manufacturer": "Shelly","model": "%shelly_model%","name": "%shelly_id%-0"}} topic=%discovery_prefix%/sensor/%shelly_id%-0/power/config payload={"name": "%shelly_id% Power 0", "stat_t": "~status/switch:0", "frc_upd": "false", "enabled_by_default": true, "uniq_id": "%shelly_id%-0-power", "qos": 0, "~": "%shelly_topic%/", "dev_cla": "power", "stat_cla": "measurement", "unit_of_meas": "W", "val_tpl": "{{ value_json.apower }}", "device": {"identifiers": ["%shelly_mac%-0"],"manufacturer": "Shelly","model": "%shelly_model%","name": "%shelly_id%-0"}} topic=%discovery_prefix%/sensor/%shelly_id%-0/energy/config payload={"name": "%shelly_id% Energy 0", "stat_t": "~status/switch:0", "frc_upd": "false", "enabled_by_default": false, "uniq_id": "%shelly_id%-0-energy", "qos": 0, "~": "%shelly_topic%/", "dev_cla": "energy", "stat_cla": "total_increasing", "unit_of_meas": "Wh", "val_tpl": "{{ value_json['aenergy'].total|float/60)|round(2) }}", "device": {"identifiers": ["%shelly_mac%-0"],"manufacturer": "Shelly","model": "%shelly_model%","name": "%shelly_id%-0"}}

I copied these lines from the Shelly Plus 1PM device. I also included the modified file.

mqtt_templates_gen2.txt

Regards Bert

Shelly1PM only sees one external temperature sensor

Just started using shellyteacher4domo and noticed that it only sees one external temp sensor when two are connected to a Shelly1PM.
In my case it only sees shelly1pm-XXXXXXXXXX-temp-1 and shelly1pm-XXXXXXXXXXXX-temperature (which is the device temp).
I have two shelly1PM's both with two external temp sensors. Both act the same.
Used latest shellyteacher4domo and latest domoticz beta.
All other devices (Shelly1, Shelly2, Shelly2.5, ShellyDimmer, ShellyDimmer2 and ShellyPlus1PM) work fine.

shellyteacher 4 installation with raspberry os Bookworm

Hi Alexander, my "test raspberry" runs with linux v12 64bits desktop edition. Below, a report of the installation of Shellyteacher 4:
sudo apt install python3-pip git : OK
python3-pip is already the most recent version (23.0.1+dfsg-1+rpt1) / same for git
sudo pip3 install paho-mqtt :
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.

If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.

I'm by far not a linux expert, so I tried something more easyer ;-) With the Add / remove software (PI desktop ) I installed python3-paho-mqtt 1.6.1-1, and the installation works !

python3 shellyteacher4domo.py :
TKInter init failed no display name and no $DISPLAY environment variable
Ini file exists
Connecting to MQTT server...
Connection failed to MQTT server at 192.168.1.2 [Errno 111] Connection refused
MQTT connection failed, alter settings and retry!

My MQTT server (mosquitto) has the IP 192.168.1.3 . After correction of settings.py, shellyteacher4 starts.

Did I something wrong, or the installation code needs to be changed ?

Thanks for your work
Regards
Marc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.