bramstroker / homeassistant-powercalc

Custom component to calculate estimated power consumption of lights and other appliances

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

shelly 1 mini gen3 with Powercalc - OK, shelly 1PM mini gen3 with Powercalc - OK, shelly PM Mini with Powercalc NOK

wagewif opened this issue · comments

System Health details

System Information

version core-2024.3.1
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.12.2
os_name Linux
os_version 6.6.20-haos
arch x86_64
timezone Europe/Vienna
config_dir /config
Home Assistant Community Store
GitHub API ok
GitHub Content ok
GitHub Web ok
GitHub API Calls Remaining 4696
Installed Version 1.34.0
Stage running
Available Repositories 1402
Downloaded Repositories 28
Home Assistant Cloud
logged_in false
can_reach_cert_server ok
can_reach_cloud_auth ok
can_reach_cloud ok
Home Assistant Supervisor
host_os Home Assistant OS 12.1
update_channel stable
supervisor_version supervisor-2024.03.0
agent_version 1.6.0
docker_version 24.0.7
disk_total 468.7 GB
disk_used 32.6 GB
healthy true
supported true
board generic-x86-64
supervisor_api ok
version_api ok
installed_addons File editor (5.8.0), Terminal & SSH (9.10.0), Log Viewer (0.17.0), WireGuard (0.10.2), InfluxDB (5.0.0), Grafana (9.2.0), Filebrowser (2.23.0_12), motionEye (0.20.0), CUPS (1.0), Nextcloud (28.0.3), Studio Code Server (5.15.0), Mosquitto broker (6.4.0), MQTT Explorer (browser-1.0.1)
Dashboards
dashboards 7
resources 23
views 27
mode storage
Recorder
oldest_recorder_run 6. März 2024 um 09:18
current_recorder_run 15. März 2024 um 20:17
estimated_db_size 650.10 MiB
database_engine sqlite
database_version 3.44.2

Checklist

  • I have read the FAQ to see if there is a known solution to my problem.
  • I have enabled debug logging for my installation.
  • I have filled out the issue template to the best of my ability.
  • This issue only contains 1 issue (if you have multiple issues, open one issue for each issue).
  • This issue is not a duplicate issue of currently previous issues..

Describe the issue

shelly 1 mini (the blue) works with Powercalc with virtual sensor
shelly 1PM (the Red) works with Powercalc with real sensor

shelly PM Mini (grey without switch) i had no chance to get it working with powercalc
I think the Problem is a missing entity_domain with this device

Reproduction steps

i tryed it 3 or 4 times i had no chance with the shelly mini PM ( grey without relais/switch)

Debug logs

2024-03-15 20:17:35.136 WARNING (SyncWorker_3) [homeassistant.loader] We found a custom integration homematicip_local which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-03-15 20:17:35.137 WARNING (SyncWorker_3) [homeassistant.loader] We found a custom integration enigma which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-03-15 20:17:35.137 WARNING (SyncWorker_3) [homeassistant.loader] We found a custom integration battery_notes which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-03-15 20:17:35.138 WARNING (SyncWorker_3) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-03-15 20:17:35.138 WARNING (SyncWorker_3) [homeassistant.loader] We found a custom integration powercalc which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-03-15 20:17:35.139 WARNING (SyncWorker_3) [homeassistant.loader] We found a custom integration delete which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-03-15 20:17:35.139 WARNING (SyncWorker_3) [homeassistant.loader] We found a custom integration weatherdotcom which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-03-15 20:17:35.139 WARNING (SyncWorker_3) [homeassistant.loader] We found a custom integration watchman which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-03-15 20:17:37.335 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up command_line platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 350, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/usr/src/homeassistant/homeassistant/components/command_line/sensor.py", line 66, in async_setup_platform
    name: str = sensor_config[CONF_NAME]
                ~~~~~~~~~~~~~^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable
2024-03-15 20:32:07.530 ERROR (MainThread) [homeassistant.helpers.event] Error while dispatching event for sensor.csensor to <Job track state_changed event {'sensor.csensor'} HassJobType.Callback <bound method TrackTemplateResultInfo._refresh of <TrackTemplateResultInfo {Template<template=({{ states.sensor.csensor.attributes["channel9"]["temperature"] }}) renders=38>: <RenderInfo Template<template=({{ states.sensor.csensor.attributes["channel9"]["temperature"] }}) renders=38> all_states=False all_states_lifecycle=False domains=frozenset() domains_lifecycle=frozenset() entities=frozenset({'sensor.csensor'}) rate_limit=None has_time=False exception=None is_static=False>}>>>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 663, in state
    numerical_value = int(value)
                      ^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 666, in state
    numerical_value = float(value)
                      ^^^^^^^^^^^^
ValueError: could not convert string to float: ''

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 330, in _async_dispatch_entity_id_event
    hass.async_run_hass_job(job, event)
  File "/usr/src/homeassistant/homeassistant/core.py", line 727, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1262, in _refresh
    self.hass.async_run_hass_job(self._job, event, updates)
  File "/usr/src/homeassistant/homeassistant/core.py", line 727, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 434, in _handle_results
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 992, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1113, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1050, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 998, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 670, in state
    raise ValueError(
ValueError: Sensor sensor.channel9_temperature has device class 'temperature', state class 'None' unit '°C' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: '' (<class 'str'>)
2024-03-15 20:32:07.551 ERROR (MainThread) [homeassistant.helpers.event] Error while dispatching event for sensor.csensor to <Job track state_changed event {'sensor.csensor'} HassJobType.Callback <bound method TrackTemplateResultInfo._refresh of <TrackTemplateResultInfo {Template<template=({{ states.sensor.csensor.attributes["channel9"]["humidity"] }}) renders=38>: <RenderInfo Template<template=({{ states.sensor.csensor.attributes["channel9"]["humidity"] }}) renders=38> all_states=False all_states_lifecycle=False domains=frozenset() domains_lifecycle=frozenset() entities=frozenset({'sensor.csensor'}) rate_limit=None has_time=False exception=None is_static=False>}>>>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 663, in state
    numerical_value = int(value)
                      ^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 666, in state
    numerical_value = float(value)
                      ^^^^^^^^^^^^
ValueError: could not convert string to float: ''

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 330, in _async_dispatch_entity_id_event
    hass.async_run_hass_job(job, event)
  File "/usr/src/homeassistant/homeassistant/core.py", line 727, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1262, in _refresh
    self.hass.async_run_hass_job(self._job, event, updates)
  File "/usr/src/homeassistant/homeassistant/core.py", line 727, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 434, in _handle_results
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 992, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1113, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1050, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 998, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 670, in state
    raise ValueError(
ValueError: Sensor sensor.channel9_humidity has device class 'humidity', state class 'None' unit '%' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: '' (<class 'str'>)
2024-03-15 20:36:00.858 ERROR (MainThread) [aioshelly.rpc_device.wsrpc] 10.0.0.71: Pong not received, device is likely unresponsive; disconnecting
2024-03-15 20:37:40.676 DEBUG (MainThread) [custom_components.powercalc.sensors.power] sensor.routera1_power: State changed to "15.00". Power:15.00
2024-03-15 20:37:40.676 DEBUG (MainThread) [custom_components.powercalc.sensors.power] sensor.wlanap_power: State changed to "9.00". Power:9.00
2024-03-15 20:37:40.687 DEBUG (MainThread) [custom_components.powercalc.sensors.power] sensor.cams_power: State changed to "25.00". Power:25.00
2024-03-15 20:37:40.692 DEBUG (MainThread) [custom_components.powercalc.sensors.power] sensor.shelly42_power: State changed to "0.00". Power:9.00
2024-03-15 20:37:40.698 DEBUG (MainThread) [custom_components.powercalc.sensors.power] sensor.shelly44_power: State changed to "8.00". Power:14.00
2024-03-15 20:37:40.699 DEBUG (MainThread) [custom_components.powercalc.sensors.power] sensor.shelly45_power: State changed to "0.00". Power:14.00
2024-03-15 20:38:16.536 DEBUG (MainThread) [custom_components.powercalc.sensors.energy] Forced energy sensor generation for the power sensor 'sensor.pm_my1_power'
2024-03-15 20:38:16.536 DEBUG (MainThread) [custom_components.powercalc.sensors.energy] Creating energy sensor: testminipm energy
2024-03-15 20:38:16.537 DEBUG (MainThread) [custom_components.powercalc.sensors.utility_meter] Creating utility_meter sensor: testminipm energy daily (entity_id=sensor.testminipm_energy_daily)
2024-03-15 20:38:16.537 DEBUG (MainThread) [custom_components.powercalc.sensors.utility_meter] Creating utility_meter sensor: testminipm energy weekly (entity_id=sensor.testminipm_energy_weekly)
2024-03-15 20:38:16.537 DEBUG (MainThread) [custom_components.powercalc.sensors.utility_meter] Creating utility_meter sensor: testminipm energy monthly (entity_id=sensor.testminipm_energy_monthly)
2024-03-15 20:38:16.538 DEBUG (MainThread) [custom_components.powercalc.sensors.utility_meter] Creating utility_meter sensor: testminipm energy yearly (entity_id=sensor.testminipm_energy_yearly)
2024-03-15 20:38:16.540 DEBUG (MainThread) [custom_components.powercalc.sensors.abstract] Binding sensor.testminipm_energy_daily to device 1a7054f56ef00a8883fc87098188b9c8
2024-03-15 20:38:16.544 DEBUG (MainThread) [custom_components.powercalc.sensors.abstract] Binding sensor.testminipm_energy_weekly to device 1a7054f56ef00a8883fc87098188b9c8
2024-03-15 20:38:16.554 DEBUG (MainThread) [custom_components.powercalc.sensors.abstract] Binding sensor.testminipm_energy_monthly to device 1a7054f56ef00a8883fc87098188b9c8
2024-03-15 20:38:16.557 DEBUG (MainThread) [custom_components.powercalc.sensors.abstract] Binding sensor.testminipm_energy_yearly to device 1a7054f56ef00a8883fc87098188b9c8

Diagnostics dump or YAML config

No response

Could you elaborate more about how what your exact configuration looks like?
You are creating virtual power sensors for a shelly 1PM? Which is in itself a smartplug with power metering, so I don't grasp what you are trying to achieve exactly. Doesn't make sense to setup a virtual power sensor for that.

shelly 1mini(blue) works with virtual sensor
shelly 1pm mini ( red) works with real sensor

shelly PMmini(grey without relais) does not work with real sensor, i think problems with entity_id without entity_domain

How did you setup the shelly PMmini? Using GUI or the YAML option.
If YAML please provide the relevant config you used.
If GUI please download diagnostics and attach them here on github. You can download these by clicking three dots at the configuration entry in powercalc page.

shelly 1 mini (blue)

  • entity_id: switch.shellymini1_robert_switch_0
    unique_id: shellymini1_1_103010508953
    fixed:
    power: 6

shelly 1pm mini (red)

  • entity_id: switch.shelly1pmminig3_papa_switch_0
    power_sensor_id: sensor.shelly1pmminig3_papa_switch_0_power
    name: "papatest 1pmmini"

I'm confused? You keep sharing configuration for things which were working correctly reading your issue report. You shared the config for the entities which are working correctly, but not the one which cuases the actual problem.
Please don't include all this information because it's totally irrelevant for the actual issue/bug.

Only include the actual information / entity which you actually experience issues with.

i tryed it today completly new.

with yaml:

  • entity_id: MiniPMG3_my1
    power_sensor_id: sensor.pm_my1_power
    name: "testpmg3mini"

Konfigurationswarnungen:

Invalid config for 'powercalc' at powercalc.yaml, line 95: Entity ID MiniPMG3_my1 is an invalid entity ID for dictionary value 'powercalc->sensors->17- >entity_id', got 'MiniPMG3_my1'

Ah I see.

entity_id must be an actual entity id, it's only needed when you want the name extracted from that.
In your case for setting up energy sensor for the power sensor you only have to provide power_sensor_id.

power_sensor_id: sensor.pm_my1_power
name: "testpmg3mini"

Hope this helps.

configuration with yaml with out entity_id not possible!

bad indentation of a mapping entry (96:2)

93 | name: "papatest 1pmmini"
94 |
95 | # - entity_id: MiniPMG3_my1
96 | - power_sensor_id: sensor.pm_ ...
-------^
97 | name: "testpmg3mini"
98 |

It's just a YAML syntax error. indentation is important in yaml.
Make sure the YAML is valid. https://www.yamllint.com/

Now i think i have it!

1.st step yaml:

- entity_id: MiniPMG3_my1

  • power_sensor_id: sensor.pm_my1_power
    name: "testpmg3mini"
  1. to add it with gui with realsensor

    now it works!