marq24 / ha-tibber-pulse-local

Local/LAN Tibber Pulse IR/Bridge Integration for Home Assistant. My Tibber invitation Link: https://invite.tibber.com/6o0kqvzf (Code: six, oscar, zero, kilo, quebec, victor, zulu, foxtrot)
Apache License 2.0
114 stars 4 forks source link

unit of measurement can not be converted #34

Closed eckerse closed 2 months ago

eckerse commented 2 months ago

Checklist

Add a description

I can not convert the unit of measurement for display e.g. from W to kW - it will show the same raw numeric value with different unit but not devide by 1k. For example for 500W, if setting the unit to kW, it will display 500kW instead of 0,5kW. For other sensors I'm using it works. I have a custom mqtt sensor where I set unit_of_measurement: "W" - here in lovelace the automatic conversion works.

I tried to look at the sourcecode but can not really see a difference in const.py in comparison to other sensors. native_unit_of_measurement=UnitOfPower.WATT looks correct to me.

Add your DEBUG log output

2024-08-27 10:49:59.436 INFO (MainThread) [custom_components.tibber_local] Starting TibberLocal with interval: 0:00:02 - ConfigEntry: {'created_at': '1970-01-01T00:00:00+00:00', 'data': {'name': 'ltibber', 'host': '<MASKED>', 'password': '<MASKED>', 'scan_interval': 2, 'node_num': 1, 'id': None, 'mode': 3}, 'disabled_by': None, 'domain': 'tibber_local', 'entry_id': '3f0810d47d42a484a56bd56b4a42da49', 'minor_version': 1, 'modified_at': '1970-01-01T00:00:00+00:00', 'options': {}, 'pref_disable_new_entities': False, 'pref_disable_polling': False, 'source': 'user', 'title': 'ltibber', 'unique_id': None, 'version': 1}
2024-08-27 10:49:59.436 INFO (MainThread) [custom_components.tibber_local] restarting TibberLocalBridge integration... for host: '192.168.178.85' node: '1' com_mode: '3' with options: {'ignore_parse_errors': False}
2024-08-27 10:49:59.516 INFO (MainThread) [custom_components.tibber_local] after init - found OBIS entries: '{'0100000009ff': <obis: 0100000009ff, value: 090149534b000432c566>, '0100010800ff': <obis: 0100010800ff, status: 65954, unit: 30, scaler: -1, value: 339962631>, '0100010801ff': <obis: 0100010801ff, unit: 30, scaler: -1, value: 339962631>, '0100010802ff': <obis: 0100010802ff, unit: 30, scaler: -1, value: 0>, '0100020800ff': <obis: 0100020800ff, unit: 30, scaler: -1, value: 404786646>, '0100020801ff': <obis: 0100020801ff, unit: 30, scaler: -1, value: 404786646>, '0100020802ff': <obis: 0100020802ff, unit: 30, scaler: -1, value: 0>, '0100100700ff': <obis: 0100100700ff, unit: 27, scaler: 0, value: -20322>, '0100240700ff': <obis: 0100240700ff, unit: 27, scaler: 0, value: -6787>, '0100380700ff': <obis: 0100380700ff, unit: 27, scaler: 0, value: -6591>, '01004c0700ff': <obis: 01004c0700ff, unit: 27, scaler: 0, value: -6941>}'
2024-08-27 10:50:03.144 INFO (MainThread) [custom_components.tibber_local.sensor] available sensors found: dict_keys(['0100000009ff', '0100010800ff', '0100010801ff', '0100010802ff', '0100020800ff', '0100020801ff', '0100020802ff', '0100100700ff', '0100240700ff', '0100380700ff', '01004c0700ff'])
2024-08-27 10:50:05.024 DEBUG (MainThread) [custom_components.tibber_local] Finished fetching tibber_local data in 0.067 seconds (success: True)
2024-08-27 10:50:07.136 DEBUG (MainThread) [custom_components.tibber_local] Finished fetching tibber_local data in 0.145 seconds (success: True)
marq24 commented 2 months ago

can you please be so kind and let me know from which internal or custom integration your "other" sensors are coming from [where this unit adjustment & convert process is working]? TIA

eckerse commented 2 months ago

For example I'm getting sensor data from EVCC via MQTT:

      unique_id: uniqueid__evcc_pc_power_w
      icon: mdi:home-lightning-bolt-outline
      state_topic: "evcc/site/pvPower"
      value_template: "{{ value | round(1) }}"
      unit_of_measurement: "W"
      device_class: "power"
      state_class: measurement
      availability_topic: "evcc/status" 

But also the sensors from official tibber app work correctly, their settings are the same as in tibber_local - thatswhy I don't really understand the difference

        device_class=SensorDeviceClass.POWER,
        state_class=SensorStateClass.MEASUREMENT,
        native_unit_of_measurement=UnitOfPower.WATT,
marq24 commented 2 months ago

the difference (currently) is, that (all my) integration have it's own implementation of the state method - while default sensor state implementation will handle all the possible convert processes, they will currently not applied in my Sensor implementation - solution would be implement a different "base" method in my sensor's... -> this will take a while

eckerse commented 2 months ago

Thanks for clarification, I was not so deep in this topic. This would be something 'nice to have', but currently more cosmetical. Another sideeffect would be that kWh and Wh entities would actually be the same.

marq24 commented 2 months ago

solved with release 2024.9.0