jedie / pysmartmeter

Collect data from Hitchi Smartmeter and expose it via MQTT
GNU General Public License v3.0
7 stars 1 forks source link

DEVICE_CLASS #21

Open dmaj opened 1 year ago

dmaj commented 1 year ago

You use the DEVICE_CLASS 'energy' for all values, even if the values refer to current or voltage. Wouldn't it make sense to use the intended classes here?

Unfortunately, I cannot test it because my meter does not output any values for voltage. But it looks to me as if only 'energy' is used.

jedie commented 1 year ago

Hm. I don't know... But it seems correct in Home Assistant for me: grafik

dmaj commented 1 year ago

I actually lack practical experience with "homeassistant" here. I went through the code of "pysmartmeeter" to see how the whole thing works together. I checked the code against the specification of the interface of "homeassistant". However, I have no experience whatsoever of the effects these parameters have on the system. As long as it works ... :-)

1 2

And two screenshots attached.

jedie commented 1 year ago

With ./cli.py dump you can see a little bit, what published via MQTT, e.g.:

grafik

But this is a layer between "RAW-Serial output" and HomeAssistant payload.

One of the tests has some "realistic" data as input and the payload to HomeAssistant is here:

https://github.com/jedie/pysmartmeter/blob/main/pysmartmeter/tests/test_homeassistant_homeassistant_mqtt_payloads_1.snapshot.json

So you can see, that there correct unit_of_measurement send. Don't know what happens or if it's better so den all voltage with "device_class": "volatge" instead of "device_class": "energy"

EDIT: Currently the device_class is hardcoded to energy... I will look, if we can set this dynamically...

jedie commented 1 year ago

I made a test in https://github.com/jedie/pysmartmeter/pull/28

and yes, it a good idea to change the device class for voltage. In the end this is the visible change in HomeAssistant:

OLD:

2023-02-26_17-32

And with #28 the icons changed, e.g.:

grafik

The payload change can be seen here: https://github.com/jedie/pysmartmeter/commit/e18294899483ab991361a28116d47d554c437242#diff-0777ab2a4f412c65a478205c3806bf571d7dd798688c33e20e8ecc6122320002

Maybe other values can also have a better class, e.g.:

    'identifier': 'Gerätetyp mit Software Version',
    '1-0:0.0.0*255': 'Eigentumsnummer',
    '1-0:96.1.0*255': 'Geräte-Identifikationsnummer',
    '1-0:96.5.0*255': 'Betriebszustand',
    '0-0:96.8.0*255': 'Betriebsdauer',

@dmaj where is a good overview about existing device classes?!?

dmaj commented 1 year ago

Sorry, i forgot to attach the links :-): Development Homeassistant Development Homeassistant Entity