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

Sensors unavailable

Jordo-o opened this issue · comments

System Health details

System Information

version core-2024.1.3
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.11.6
os_name Linux
os_version 6.1.63-haos-raspi
arch aarch64
timezone Europe/Amsterdam
config_dir /config
Home Assistant Community Store
GitHub API ok
GitHub Content ok
GitHub Web ok
GitHub API Calls Remaining 4993
Installed Version 1.33.0
Stage running
Available Repositories 1385
Downloaded Repositories 31
HACS Data ok
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 11.4
update_channel stable
supervisor_version supervisor-2023.12.0
agent_version 1.6.0
docker_version 24.0.7
disk_total 13.7 GB
disk_used 8.2 GB
healthy true
supported true
board rpi4-64
supervisor_api ok
version_api ok
installed_addons ESPHome (2023.12.6)
Dashboards
dashboards 4
resources 24
views 6
mode storage
Recorder
oldest_recorder_run January 8, 2024 at 15:57
current_recorder_run January 14, 2024 at 22:53
estimated_db_size 214.23 MiB
database_engine sqlite
database_version 3.41.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

Device power sensors are unavailable when device is offline, even when "Ignore unavailable state" is enabled.

Reproduction steps

  1. Make sure Ignore unavailable state is enabled
  2. Let device go offline
  3. See sensors go unavailable too

Debug logs

2024-01-16 09:36:36.695 DEBUG (MainThread) [custom_components.powercalc.sensors.power] Creating power sensor (entity_id=media_player.playstation_4 entity_category=None, sensor_name=Playstation 4 power strategy=fixed manufacturer= model= unique_id=powercalc_playstation_4)
2024-01-16 09:36:36.695 DEBUG (MainThread) [custom_components.powercalc.sensors.energy] Creating energy sensor: Playstation 4 energy
sensor.playstation_4_power to device a547c885db99f7bcd10527293ffcedbe
2024-01-16 09:36:36.717 DEBUG (MainThread) [custom_components.powercalc.sensors.abstract] Binding sensor.playstation_4_energy to device a547c885db99f7bcd10527293ffcedbe
2024-01-16 09:36:36.725 INFO (MainThread) [homeassistant.components.sensor] Setting up powercalc.sensor
2024-01-16 09:36:37.069 DEBUG (MainThread) [custom_components.powercalc.sensors.power] media_player.playstation_4: Source entity has an invalid state, setting power sensor to unavailable

Diagnostics dump or YAML config

{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2024.1.3",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.11.6",
    "docker": true,
    "arch": "aarch64",
    "timezone": "Europe/Amsterdam",
    "os_name": "Linux",
    "os_version": "6.1.63-haos-raspi",
    "supervisor": "2023.12.0",
    "host_os": "Home Assistant OS 11.4",
    "docker_version": "24.0.7",
    "chassis": "embedded",
    "run_as_root": true
  },
  "custom_components": {    
    "battery_notes": {
      "version": "1.4.0",
      "requirements": []
    },
    "powercalc": {
      "version": "v1.9.17",
      "requirements": [
        "numpy>=1.21.1"
      ]
    },
    "hacs": {
      "version": "1.33.0",
      "requirements": [
        "aiogithubapi>=22.10.1"
      ]
    }
  },
  "integration_manifest": {
    "after_dependencies": [
      "integration",
      "utility_meter"
    ],
    "codeowners": [
      "@bramstroker"
    ],
    "config_flow": true,
    "dependencies": [
      "light",
      "group",
      "template",
      "select",
      "utility_meter"
    ],
    "documentation": "https://github.com/bramstroker/homeassistant-powercalc",
    "domain": "powercalc",
    "iot_class": "local_polling",
    "issue_tracker": "https://github.com/bramstroker/homeassistant-powercalc/issues",
    "name": "Powercalc",
    "requirements": [
      "numpy>=1.21.1"
    ],
    "version": "v1.9.17",
    "is_built_in": false
  },
  "data": {
    "entry": {
      "entry_id": "932e3139863d11d68a99ce4a69bbbfdd",
      "version": 2,
      "minor_version": 1,
      "domain": "powercalc",
      "title": "Playstation 4",
      "data": {
        "mode": "fixed",
        "create_energy_sensor": true,
        "create_utility_meters": false,
        "entity_id": "media_player.playstation_4",
        "name": "Playstation 4",
        "unique_id": "powercalc_playstation_4",
        "standby_power": 1.3,
        "fixed": {
          "states_power": {
            "playing": 75.2,
            "paused": 41.8,
            "idle": 41.8,
            "unknown": 0.2,
            "Unknown": 0.2
          }
        },
        "ignore_unavailable_state": true,
        "energy_integration_method": "left",
        "unavailable_power": 0.2,
        "sensor_type": "virtual_power",
        "_power_entity": "sensor.playstation_4_power",
        "_energy_entity": "sensor.playstation_4_energy"
      },
      "options": {},
      "pref_disable_new_entities": false,
      "pref_disable_polling": false,
      "source": "user",
      "unique_id": "powercalc_playstation_4",
      "disabled_by": null
    }
  }
}

Let's focus on single entity first, as I'm not sure reading your bug report which entity you are experiencing the issue with.

The config entry (diagnostics) you shared is about the media_player.playstation_4.

Let's focus on single entity first, as I'm not sure reading your bug report which entity you are experiencing the issue with.

The config entry (diagnostics) you shared is about the media_player.playstation_4.

That is correct, the PlayStation gives the problem.
When it is in "sleep mode" its working fine. But when it is off, the network connection is inactive and the power sensor goes to unavailable.

I have made a small change. Could you try again by installing the master branch? You can do that in HACS by clicking reinstall, and select master from the list. Also check the "beta" checkbox.

When still not working please also share the actual state of media_player.playstation_4 when you experience the issue. You can find the current state in Developer tools, left menu.

It looks like it is working now.
The media_player.playstation_4 is now showing 0.2 watts (the unavailable power from the settings).

Ok, that's great. Will be released in next version. closing this issue