enesbcs / shellyteacher4domo

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

Can't computed energy Shelly Plus 1 PM #9

Closed TheReiner closed 1 year ago

TheReiner commented 1 year ago

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

enesbcs commented 1 year ago

I cant see any difference in the important parameters. Maybe if you enable Domoticz debug log and see what kind of devices it creates for you, it will help.

Shelly Dimmer: payload={"name": "%shelly_id% 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": "%shelly_id%-light-power-0", "qos": 0, "~": "shellies/%shelly_id%/", "dev_cla": "power", "stat_cla": "measurement", "unit_of_meas": "W", "val_tpl": "{{value|float|round(1)}}","device": {"identifiers": ["%shelly_mac%"],"manufacturer": "Shelly","model": "%shelly_model%","name": "%shelly_id%"}}

Shelly Plus1PM: 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"}}

TheReiner commented 1 year ago

Sorry, i forget to tell you... for my Shelly Dimmer, i use the old plug-in Shelly MQTT for Domoticz...

enesbcs commented 1 year ago

The old plugin creates devices for itself, but Domoticz MQTT AD hardware creates the devices in this case. I guess this is the way how MQTT AD works now. You can open an issue on Domoticz github for this problem.

TheReiner commented 1 year ago

Thanks...

But i think is not a problem from Domoticz...

In SQL (DeviceStatus) my Shelly Plus 1 PM is Type 248 and subtype 1 and option is "1;" And for my Dimmer... The Type 243 and subtype 29 and Option is "EnergyMeterMode:MQ=="

enesbcs commented 1 year ago

But i think is not a problem from Domoticz...

MQTT config documentation for "Sensor" type: https://www.home-assistant.io/integrations/sensor.mqtt/

I see 3 point where we can tell Domoticz which kind of sensor we want: "dev_cla": "power", "stat_cla": "measurement", "unit_of_meas": "W"

And these are the standard device types: https://developers.home-assistant.io/docs/core/entity/sensor/#available-device-classes

Maybe you can try alter class or state_class to "total_increasing" but as i see in the Domoticz source code, it is only watching for the unit of measurement and creates a specific kind of device if it is "W".

TheReiner commented 1 year ago

Ok many thanks, maybe it's the solution... But i don't know the process...

I have changed the template ... in "mqtt_templates_gen2.txt" ans i have deleted in domoticz the device... and i haved exec "python3 shellyteacher4domo.py" is it good ? (new device, but same problem and i think it's not with the new template)

enesbcs commented 1 year ago

The process is good. You can enable debug in setup.py to see the sent mqtt payloads.. but do not forget to disable debug, after checking.

enesbcs commented 1 year ago

In SQL (DeviceStatus) my Shelly Plus 1 PM is Type 248 and subtype 1 and option is "1;" And for my Dimmer... The Type 243 and subtype 29 and Option is "EnergyMeterMode:MQ=="

243/29 is a General/Electric (Instant+Counter) device which has a unit of kWh this is created by Domoticz when unit is "kWh" .. and only this kind of device has the option for "Compute".

248/1 is a Usage / Electric device is created by Domoticz MQTT AD when unit is "W"

Most of Shelly devices returns watt-minutes, which needs to be translated to kwh first, but it is currently not supported in Domozicz, see issue: https://github.com/enesbcs/shellyteacher4domo/issues/6