FreshlyBrewedCode / hacs-homee

a Home Assistant custom component to integrate the homee smart home platform
MIT License
17 stars 6 forks source link

Question: Configure imported sensor #11

Closed hajo62 closed 1 year ago

hajo62 commented 2 years ago

How would I configure how a sensor get's imported. I.e. my Fibaro wall plug is shown like this. Entity state attributes:

current_power_w: 0
today_energy_kwh: 1.94
homee_data:
  id: 11
  name: FIBARFO Wall Plug
  profile: 13
  attributes:
    - id: 100
      type: 1
    - id: 101
      type: 44
    - id: 102
      type: 45
    - id: 103
      type: 4
    - id: 104
      type: 47
    - id: 105
      type: 48
    - id: 106
      type: 3
    - id: 107
      type: 347
friendly_name: FIBARFO Wall Plug

file core.entity_register:

               "entity_id": "switch.fibaro_wall_plug",
                "config_entry_id": "7cc80fde59fca178fd33364",
                "device_id": null,
                "area_id": null,
                "unique_id": "11-switch-100",
                "platform": "homee",
                "name": "Fibaro Wall Plug",
                "icon": null,
                "disabled_by": null,
                "capabilities": {},
                "supported_features": 0,
                "device_class": "outlet",
                "unit_of_measurement": null,
                "original_name": "FIBARO Wall Plug",
                "original_icon": null,
                "entity_category": null

I would like to i.e. the unit_of_measurement: kWh (uppercase W) and maybe set the state_class: total_increasing. I would hope, that this device than is available to the new energy dashboard.

FreshlyBrewedCode commented 2 years ago

There is no extra configuration you can do using the integration. But maybe you can achieve this using the entity customization in HA. Regular sensor entities are currently not supported. The sensor capabilities of plugs are implemented in the switch entity using the attributes of the SwitchEntity. However, they seem to be deprecated which may be why the entities do not show up on the new energy dashboard. Maybe you can use template entities as a workaround.

hajo62 commented 2 years ago

Thanks for your info. Will have a loock at it.

But I still have a question: The plug entities have an attribute today_energy_kwhwhich I assume is created by your integration. Shouldn't that be a total energy with kWh as unit?

FreshlyBrewedCode commented 2 years ago

today_energy_kwh is implemented in switch.py:

@property
def today_energy_kwh(self):
    """Return the total power usage in kWh."""
    if self.has_attribute(AttributeType.ACCUMULATED_ENERGY_USE):
        return self.attribute(AttributeType.ACCUMULATED_ENERGY_USE)
    else:
        return None

this was implemented by @BetaTobi in #7. It just returns the ACCUMULATED_ENERGY_USE attribute from homee. I am not entirely sure what that value exactly represents in homee.

hajo62 commented 2 years ago

At least for my Fibaro and my Cyrrus plugs the values shown in today_energy_kwh are the all time accumulation starting from last reset and not a kind of accumulation per day.

Would it be possible to change today_energy_kwhto total_energy_kwh?

And accoording to the new energy dashboard (and to the International System of Units, the unit should be written with an uppercase W -> kWh. With an lowercase w the home assistant energy dashboard does not recognize the sensor as an energy sensor.

BetaTobi commented 2 years ago

Correct. "today_energy_kwh" is the total accumulated energy (not just of one single day). However, this naming has been done on HA side, not within this integration.

image

hajo62 commented 2 years ago

Okay, that means that this could not be changed on your side.

When I look at the current_power_w, it looks like the unit provided is kWh, althoug it should be W.

Do you have an idea, why energy dashboard does not recognize/offer my sensors?

BetaTobi commented 2 years ago

I just double-checked in my HA configuration. "current_power_w" returns the current power of my plugs, in Watt. So this should be correct.

But I do not know, why the energy dashboard does not recognize your sensors. Actually, I did not yet use the energy dashboard :-) But I will have a look now, and if I find something, I will report it (here).

FreshlyBrewedCode commented 2 years ago

As I said before, according to the docs these properties are deprecated for the switch entity. Unfortunately, I believe the switches won't show up on the new energy dashboard unless the information about the power is migrated to a separate sensor entity. image

hajo62 commented 2 years ago

May mistake. I had tried to do a customization for one of the sensor: Without customization they do not show any unit of measurement:

grafik
Stklingner commented 1 year ago

I've got the sensors working as separate entities on my branch - tidying it up before merging hopefully this weekend:

Screenshot 2022-10-14 at 9 39 42 am Screenshot 2022-10-14 at 9 40 00 am
github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 2.0.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: