Giter Site home page Giter Site logo

rbrink / home-assistant-prijsplafond Goto Github PK

View Code? Open in Web Editor NEW
11.0 4.0 3.0 53 KB

Provides Home Assistant sensors to keep track of the Dutch prijsplafond regulation.

Python 100.00%
energie gas maximumtarief prijsplafond hassio sensor hacs home-assistant home-assistant-sensor home-assistant-component

home-assistant-prijsplafond's People

Contributors

e11en avatar rbrink avatar thefes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

home-assistant-prijsplafond's Issues

Sensor unavailable

Hi,

I have setup this inside hacs and insert the config to the sensor.yaml (changed the utility sensors to my own sensors)

I see now the sensor.prijsplafond_gas and stroom
But the other sensors are unavailable, is this an matter of time they are working?

Prijsplafond values get off during short downtime for backup

I notice the following:

afbeelding

Same for gas. Currently this month about 114kWh has been used.
What happens at 3AM? A cronjob stops the HomeAssistant-container to backup the data-directory.

My workaround will be to skip this backup. I also make a backup with open files which I fortunately hadn't to restore (as well as the regular backup). Wondering what can cause this...

Error after update HA to 2023.5.0

After updating HA to 2023.5.0 the prijsplafond sensor don't work anymore. I tested it on 2 systems, both the same errors.
This is the error I get from the logs:

Logger: homeassistant.helpers.entity
Source: components/recorder/table_managers/recorder_runs.py:85
First occurred: 08:40:06 (6 occurrences)
Last logged: 08:50:06

Update for sensor.prijsplafond_gas fails
Update for sensor.prijsplafond_power fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 554, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 784, in async_device_update
    await coro
  File "/config/custom_components/prijsplafond/sensor.py", line 172, in async_update
    pos_usage += await self._get_value(entity_id)
  File "/config/custom_components/prijsplafond/sensor.py", line 192, in _get_value
    state_old = await self._get_first_recorded_state_in_month(entity_id)
  File "/config/custom_components/prijsplafond/sensor.py", line 214, in _get_first_recorded_state_in_month
    history_list = await get_instance(self.hass).async_add_executor_job(
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/recorder/history/__init__.py", line 174, in state_changes_during_period
    return _target(
  File "/usr/src/homeassistant/homeassistant/components/recorder/history/modern.py", line 404, in state_changes_during_period
    run_start_ts := _get_run_start_ts_for_utc_point_in_time(hass, start_time)
  File "/usr/src/homeassistant/homeassistant/components/recorder/history/modern.py", line 583, in _get_run_start_ts_for_utc_point_in_time
    run = recorder.get_instance(hass).recorder_runs_manager.get(utc_point_in_time)
  File "/usr/src/homeassistant/homeassistant/components/recorder/table_managers/recorder_runs.py", line 85, in get
    if start >= self.recording_start:
TypeError: can't compare offset-naive and offset-aware datetimes

Is there a way to fix this?

Strange drop in graph at (random) time?

Pluim003 reported the following graph:

image

The questions to answer:

  • What is causing this drop?
  • Is the drop occuring at the same time every day?

My data shows the following:

image
With no drop..

Plafond "Power" Error

Only the power fails over here. Gas is working.

Using dsmr.month.merged sensor or using dsmr.month.low and dsmr.month.high sensors.
All the 3 sensors are visible in HA. And outout is kWh.

I do get the next error:

Logger: homeassistant.helpers.entity
Source: custom_components/prijsplafond/sensor.py:194
Integration: Prijsplafond (documentation, issues)
First occurred: 16:37:32 (2 occurrences)
Last logged: 16:43:02

Update for sensor.prijsplafond_power fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 538, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 736, in async_device_update
raise exc
File "/config/custom_components/prijsplafond/sensor.py", line 172, in async_update
pos_usage += await self._get_value(entity_id)
File "/config/custom_components/prijsplafond/sensor.py", line 194, in _get_value
usage = float(state_old.state)
ValueError: could not convert string to float: 'unknown'

Examples from README.md modified (so no bug)

In my template.yaml I added

  - sensor:

      # Template sensor to display the current monthly cap.
      - name: 'Prijsplafond monthly gas cap'
        unit_of_measurement: "m.."
        state: "{{ state_attr('sensor.prijsplafond_gas', 'this_month_cap') }}"

      - name: 'Prijsplafond monthly power cap'
        unit_of_measurement: "kWh"
        state: "{{ state_attr('sensor.prijsplafond_power', 'this_month_cap') }}"

Had to replace value_template by state and remove the friendly-name as it isn't being used (anymore).

Based on these values and the current monthly usage it should be possible to make sensors for remaining gas and power for current month

Maybe someone knows how to get that correct in the code below:

     - name: 'Prijsplafond remaining gas'
        unit_of_measurement: "m.."
        state: "{{ state_attr('sensor.prijsplafond_gas', 'this_month_cap') -
                   states('sensor.prijsplafond_gas') }} "

      - name: 'Prijsplafond remaining power'
        unit_of_measurement: "kWh"
        state: "{{ state_attr('sensor.prijsplafond_power', 'this_month_cap') -
                   states('sensor.prijsplafond_power') }}"

New entities after update

Hello,

I'm using this intergration since like it started at begiining of January.

Today I got mention of an update being available so I read the readme and changelog. Then removed the platform from my configuration.yaml, restarted HA. Then did the update from HACS and restarted HA again.
After restart went to add the integration again. It showed the config flow however no text :
Screenshot_20230124_183551_Home Assistant
After selecting the correct sensors the intergration adding was succesful.

But looking at my entities I now we them as new entities instead of the already created ones :
Screenshot_20230124_184132_Home Assistant

HAOS on VM
Language set to English, location set to Netherlands.

How can I get them inline again ?

Adding integration directly

When I add the integration directly I'm prompted to enter the entities to be used for prijsplafond but the one for gas can't be chosen:

afbeelding

The screenshot doesn't contain more entities to choose from but gas is missing.

This is causing that my gas usage for the months is now set to 0.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.