enesbcs / shellyteacher4domo

Shelly device teacher for Domoticz MQTT Autodiscovery hardware
Apache License 2.0
10 stars 4 forks source link

Shelly PlusPlugS gen2 power, voltage and energy devices in domoticz #11

Closed Bertels999 closed 1 year ago

Bertels999 commented 1 year ago

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

enesbcs commented 1 year ago

Thanks, added at commit https://github.com/enesbcs/shellyteacher4domo/commit/7b68c24ba1eb6364e6a1eec982b8a93caa4a46ee