jobvk / Home-Assistant-Windcentrale

Provides Home Assistant sensors for multiple wind turbines from the Windcentrale
https://jobvankoeveringe.com/projects/windcentrale/
Apache License 2.0
14 stars 3 forks source link

Sensor is made availabe for Energy Management tab #6

Closed Simanias closed 2 years ago

Simanias commented 3 years ago

Checklist

The Feature Request

Via these parameters which should be in the customize.yaml of your Home Assistant instance, the sensor is made available for the Energy Management tab. Replace the sensor.'name' with your name for the winddelen energy sensor. After this, restart your Home Assistant instance and add the winddelen sensor via Configuration > Energy > Add Return > Select your windelen sensor.

Example Code snippet


sensor.'name':
  state_class: total_increasing

Additional information

No response

jobvk commented 3 years ago

I'm already testing this for a week of two. Every day sensor has now attribute "last_reset" and "state_class".

image

The state_class is "total" and not "total_increasing" because of energy use of the windturbine. If the windturbine is not spinning the windturbine can use more power than it produces. Found this on their site:

image

But there is also the problem of putting the data inside home assistant. The API of the production history updates every couple of minutes. But as seen on the image below the API update after 06:59 an changes the data of the windcentrale graph. But I can't update home assistant state because the hour is already past.

Home Assistant image Windcentrale app image

@Simanias If you want to help me with this problem solving please add me on discord

Next week i'm going to check if it is possible to override data after the hour has been passed.

creativethings commented 2 years ago

Hey, I am trying to get this working. However I am not getting very far :( I added

sensor.het_rode_hert:
  state_class: total_increasing

I cannot add the sensor to the energy panel however, it is not even listed in Configuration > Energy > Add Return I'm using v0.1.1 of the integration.

Any suggestions? many thanks!

jobvk commented 2 years ago

@creativethings @Simanias I created a beta(pre-release) 0.1.2-beta

With this pre-release you can add sensor to the Energy Management tab but the graph is still perfect. Because I haven't found a solution to update home assistant after the hour/day past.

Simanias commented 2 years ago

@jobvk with the beta release the sensor can indeed be selected in the energy management tab, great work. Hopefully you're able to sort things out with regard to the wrong timing.

creativethings commented 2 years ago

Hi @jobvk, I can confirm it works with the 0.1.2. release for "Het Rode Hert" as well, great! I do not have multiple mill shares I am sorry, so I cannot test that scenario.

I am wondering where best to add the sensor. As far as I can see there is no way to create additional energy sources (or did i miss something?), but I can add it as fake solar result, in which case it shows up as part of my solar data.

In reality the power produced ofcause never enters my house and gets taken into account only at billing time. I was wondering therefor if it would make sense to add the winddeler result to the Net consumption, but then as a negative value. Benefit would also be that it automatically shows up in the energy consumption chart as a separate value. For that to be correct I would have however have to be able to set negative values. How would I do that?

I added this to connfiuration.yaml and although the value is calculated correctly, I cannot add it to the energy panel as a value :(

  - platform: template
    sensors:
        het_rode_hert_virtual_consumption:
        friendly_name: 'Het Rode Hert productie virtueel'
        unit_of_measurement: "kWh"  
        device_class: energy
        value_template: >-
            {{ ( states('sensor.het_rode_hert') | float / -1000 )  | round(2) }}

Any thoughts on this?

jobvk commented 2 years ago

Hi @creativethings, Good to hear it's working.

Your virtual sensor is W not kWh so that can be one reason it doesn't work. If you want to W to kWh you can use Riemann sum

If you want your virtual sensor in to Energy Management tab you van try this:

homeassistant:
  customize_glob:
    sensor.het_rode_hert_virtual_consumption:
      last_reset: "1970-01-01T00:00:00+00:00"
      device_class: energy
      state_class: total

You maybe have to change the value depending on your need.

https://developers.home-assistant.io/docs/core/entity/sensor/

device_class

device_class: power Supported units: W & kW. Power, statistics will be stored in W. device_class: energy Supported units: Wh, kWh, MWh. statistics will be stored in kWh.

state_class

state_class: measurement is best if the values changes every time in to something. (No last_reset is necessary) state_class: total is best if the value is only going up and down is a line. You have to use last_reset. state_class: total_increasing is best if the value is only going up. You have to use last_reset.

vressel commented 2 years ago

Hi,

I'm a newbie at HomeAssistant, and trying to make the output of my 2 shares of the "De Blauwe Reiger" visible in the EnergyManagementTab.

I now made this template:

- name: Wind Totaal kWh
  unit_of_measurement: "kWh"
  state: "{{ '%0.2f' | format(states('sensor.de_blauwe_reiger_total_production') | float(default=0) * 1000)  }}"
  state_class: total_increasing
  device_class: energy

Because the value is only going up I can use total_increasing, so there's no bother with last_reset.

It would be nicer if the output had better resolution and should be in Wh, and because my shell-scripting is much better than my python-programming:

VALUE=$(curl -s https://zep-api.windcentrale.nl/production/131 | grep LIFETIME | awk -F\" '{print $(NF-1)}' | awk -FE '{print $1}' ) VALUE_Wh=$(echo $VALUE * 10000000000 / 5534 * 2 | bc)

This should give you the value of shares for the lifetime of the windmill in Wh.

Is it possible to add this to the Windcentrale-integration?

jobvk commented 2 years ago

Hi @vressel,

Why do you want to use the sensor.de_blauwe_reiger_total_production sensor? If you use version 0.1.2 you can add sensor.de_blauwe_reiger_day_production to the Energy Managemen Tab and it works perfectly fine.

The reason why it's "total" and not "total_increasing" van be found here:

The state_class is "total" and not "total_increasing" because of energy use of the windturbine. If the windturbine is not spinning the windturbine can use more power than it produces. Found this on their site:

image

The year_production & total_production are in MWh, it's the same electric unit as used in their app. It's easy to read. If you change it to Wh the output would be a really long value with a lot of decimals, and that's not really easy to read.

So I Don't see a point why I should change the value to Wh.

vressel commented 2 years ago

Hi @jobvk

Thnx for your reaction.

I think I'm using 0.1.2 (according to custom_compnents/windcentrale/manifest.json), but selecting sensor.de_blauwe_reiger_day_production gives a message"unexpected state class".

I can modify customize.yaml: sensor.de_blauwe_reiger_day_production: state_class: total

but then it messes up my view:

image

image

jobvk commented 2 years ago

@vressel please create a new issue. Please include log or picture of the error. And witch step it took to create this error.

Then I'll look in to the problem