that’s the only thing I can find in the log for “sensor.handy_karsten_power”.
2022-11-22 19:44:00.462 DEBUG (MainThread) [custom_components.powercalc.sensors.abstract] Binding sensor.handy_karsten_power to device 4023ab379859bb5280b8670da540d461
after restart i found this error, too:
2022-11-22 19:51:45.948 WARNING (MainThread) [homeassistant.components.integration.sensor] sensor.handy_karsten_energy could not restore last state unknown: [<class 'decimal.ConversionSyntax'>]
Could you make an issue on github please, with the full powercalc configuration of this entity? I will see if I can reproduce.
edit
Sorry I did have a closer look into your ogirinal post, but I see you’ve put power: in the power field of the GUI configuration flow.
You must directly put in the template there, of a fixed power value. So in your case {{ iif(is_state('sensor.iphone_von_karsten_battery_state_2', 'Charging'), 10.5, 0.1) }}
Also you must put this in “Leistung-template” field.
2 questions as I have over 70 switches and plugs to setup;
Can you share approx standby power of the older zwave fibaro build in switches and dimmers and zigbee plugs? Same for quibino build in switches and dimmers.
What would be the best approach to add all of these efficiently? I have a list of all entities as they are already part of groups, is the only way to take them one by one or is there a method to bulk add and then finetune over the next few weeks? Ps yaml is no issue
Can you share approx standby power of the older zwave fibaro build in switches and dimmers and zigbee plugs? Same for quibino build in switches and dimmers.
Unfortunately not (yet). I have some fibaro dimmer 2 and other fibraro switches, but it was a real struggle to get them to fit, so I don’t have plans to disconnect them to measure short term.
Maybe someone else will be able to and have some easily accesible to connect a power meter in parallel.
What would be the best approach to add all of these efficiently? I have a list of all entities as they are already part of groups, is the only way to take them one by one or is there a method to bulk add and then finetune over the next few weeks? Ps yaml is no issue
Yes as Arganto suggest. You can also have a look into YAML anchors which would prevent a lot of duplication. Or do some magic with sublime text or other text editors.
Thanks for quick response. Started with some audio devices which are a mix of several scenarios to ‘practice’. Created below which I think is correct.
It’s a mix of Sonos (manual), sensors already created by auto discovery (the 2 bottom ones, these are Google mini’s and their sensors are working)) and 2 Google Home hubs based on the LUT.
All individual sensors are showing values but the group shows unknown. It probably has to do with the last two entries as these come from the ‘discovery’ but not sure how to fix
- platform: powercalc
create_group: All Sonos and Home
entities:
- entity_id: media_player.hobbyruimte #sonos 1 checked
fixed:
states_power:
playing: 8.3
paused: 4.4
idle: 4.4
- entity_id: media_player.keuken #sonos 1 checked
fixed:
states_power:
playing: 8.3
paused: 4.4
idle: 4.4
- entity_id: media_player.garage #sonos 1 kantoor 1 checked
fixed:
states_power:
playing: 16.6
paused: 8.8
idle: 8.1
- entity_id: media_player.move #sonos move checked
fixed:
states_power:
playing: 8.3
paused: 3.2
idle: 3.2
- entity_id: media_player.googlehomehub4983 #Luuk hub checked
manufacturer: Google
model: Home
- entity_id: media_player.lenovosmartdisplay80966 # Kitchen hub checked
manufacturer: Google
model: Home
- entity_id: sensor.family_room_speaker_energy #checked come from discovery
- entity_id: sensor.home_mini_robin_energy # checked come from discovery
I would suggest to create the powercalc group with the GUI which makes things easier.
Alternatively you can refer to existing power/energy sensors like this, as entity_id needs to be the source entity id where the virtual power/energy sensors are based on.
Thanks. Before reading this I just removed the auto detected from the integration and then added them like below. Is that also an option (group sensor seems to work) ? Then at least I have all the stuff in one place.
- entity_id: media_player.family_room_speaker # TV room
ignore_unavailable_state: true
manufacturer: Google
model: Google Home Mini
So, now started on the lights. First are the ones that already have a power sensor build in as I can match that with a manual a sensor I made in the past that combines all measurable lights.
I have the total matching but I’m surprised about that as I was expecting that the ‘standby_power’ (my proxy for the energy use of the build in zwave device) would be added, but it is not.
Below a small part of the yaml. Can’t I use standby_power in this case?
- platform: powercalc
create_group: All measured lights
entities:
- entity_id: light.fibaro_system_fgd212_dimmer_2_level_2
power_sensor_id: sensor.fibaro_system_fgd212_dimmer_2_level_2_power_2
standby_power: 1
name: TV room overhead light
- entity_id: switch.fibaro_system_fgwpef_wall_plug_gen5_switch
power_sensor_id: sensor.fibaro_system_fgwpef_wall_plug_gen5_switch_power_2
standby_power: 1
name: Piano light
- entity_id: light.qubino_zmnhdd1_flush_dimmer_level_11_0
power_sensor_id: sensor.qubino_zmnhdd1_flush_dimmer_level_11_0_electric_consumption_w
standby_power: 1
name: Kitchen main
And next to above stumbling on another issues (or question). I already have some devices I’m measuring BOTH power and energy and I was expecting that below would work. The objective would be to have powercalc create the utility meters and make use of the nesting.
Why does below throw error in the log (and not create the utility sensors?)? ps I have tried to remove “name” as a field but that did not change the outcome and to be complete, all my other utility meters from powercalc are created nicely, it’s only this part that causes problems.
Logger: homeassistant.components.sensor
Source: custom_components/powercalc/sensors/energy.py:211
Integration: Sensor (documentation, issues)
First occurred: 15:02:24 (1 occurrences)
Last logged: 15:02:24
Error while setting up powercalc platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 281, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/powercalc/sensor.py", line 248, in async_setup_platform
await _async_setup_entities(hass, config, async_add_entities, discovery_info)
File "/config/custom_components/powercalc/sensor.py", line 290, in _async_setup_entities
entities = await create_sensors(hass, config, discovery_info)
File "/config/custom_components/powercalc/sensor.py", line 421, in create_sensors
(child_new_sensors, child_existing_sensors) = await create_sensors(
File "/config/custom_components/powercalc/sensor.py", line 421, in create_sensors
(child_new_sensors, child_existing_sensors) = await create_sensors(
File "/config/custom_components/powercalc/sensor.py", line 448, in create_sensors
new_entities = await create_individual_sensors(
File "/config/custom_components/powercalc/sensor.py", line 549, in create_individual_sensors
await create_utility_meters(hass, energy_sensor, sensor_config)
File "/config/custom_components/powercalc/sensors/utility_meter.py", line 56, in create_utility_meters
name = f"{energy_sensor.name} {meter_type}"
File "/config/custom_components/powercalc/sensors/energy.py", line 211, in name
return self._entity_entry.name or self._entity_entry.original_name
AttributeError: 'NoneType' object has no attribute 'name'
When you use power_sensor_id that would be the power sensor and all other config settings for power sensors would be ignored, because powercalc does not create a new virtual power sensor but just uses what is provided in power_sensor_id
Fibaro Dimmer 2 also supports a setting to include the self usage of the device, so I suggest to turn that on. It will show ~0.3W when off.
Would it not be more logical (and consistent with powercalc sensors that calculate the power themselves) to include anything declared in standby_power in the total? Your integration creates an energy sensor based on the power sensor. This newly created energy sensor can also include “standby_power” + either “actual measured power” or “calculated power by your integration”.
This will be very complex to implement.
The energy sensor uses the power sensor as the source (this is just a riemann sum integral sensor, similar as you create with the helpers in HA), there is no way I can dynamically add standby_power to this.
It needs to be added to the power sensor, but here a similar problem arises as this is an existing power sensor provided by another integration. There is no way you can add some value to that as this entity is owned and controlled by another integration.
The only way would be to create a virtual power sensor and somehow add the state power_sensor_id to that, maybe with a template.
Or let it create a virtual power sensor only for the standby and a group sensor which combines the power_sensor_id and standby power sensor into one.
But this will need an overhaul on a lot of parts of the architecture and complicate things a lot.
The integration needs to stay maintainable to cope with issues / bugs and allow for adding new features.
I foresee this will complicate the integration too much for an edge case like this, so this is really a no go for me.