HomeWizard Energy (Wi-Fi P1 meter, kWh meter, Energy Socket and Water Meter)

I’m trying to replicate the graph in the energy dashboard to a apexcard so you’re able to do more with it.
the million-dollar question is, how is the gas graph calculated in the energy dashboard? anyone knows?

getting close but still far away.

:tada: Recently @frenck and I have been working hard on the HomeWizard Energy integration. Many things around error handling and stability have been addressed and a lot of new features have been added. You can now, if the smart meter supports this, read things such as volts and frequency.

For Belgian users, a very important sensor is now also available: Peak demand. With these sensors you can see the average of the current quarter and maximum usage of this month and act on it. You could keep your peak as low as possible with automations.

For those who would like to use the products without cloud and app: You can now also turn off the cloud connection via the UI with a simple switch. With this they work fully locally. You will then not be bothered by the annoying red flashing light if you block the connection with a firewall.

Make sure you have Home Assistant 2023.2 or later and that the HomeWizard products are up-to-date, the latter will happen automatically if they are connected to the cloud.

Learn more about all features here: HomeWizard Energy - Home Assistant

1 Like

Hi, I have a question about the gas’s usage registration. As the gas usage is only updated once an hour the usage is registers a hour late.
For example my house is using 1 m3 gas between 08:00 and 09:00. The usage is updates at 09:00 by the energy+ app as usage between 08:00 and 09:00. Home assistant has updates the usage at 09:00:15 and register the usage between 09:00 and 10:00.

I think everything on the server is configured to use the correct time zone. Is this something to live with or something I can change in the configuration or is it a big to register on gitlab?

This is a side effect of your gas meter only sending the usage once every hour. I am afraid there is nothing you can do about this except asking for an DSMR5.0 meter (which updates every 5 minutes).

Fabian, just a question, where are the prices set?

Have input numbers:

##############################
## input_number             ##
##############################


input_number:
  t2_energy_cost:
    name: Stroom import nomaal
    mode: box
    min: 0
    max: 100
    unit_of_measurement: "€/kWh"
    icon: mdi:currency-eur

  t1_energy_cost:
    name: Stroom import dal
    mode: box
    min: 0
    max: 100
    unit_of_measurement: "€/kWh"
    icon: mdi:currency-eur

  gas_energy_cost:
    name: Gas
    mode: box
    min: 0
    max: 100
    unit_of_measurement: "€/m3"
    icon: mdi:currency-eur

and a simple card:

type: entities
entities:
  - entity: input_number.t2_energy_cost
  - entity: input_number.t1_energy_cost
  - entity: input_number.gas_energy_cost
theme: Mushroom Square

2023-02-14 22_50_08-Overview – Home Assistant en nog 1 andere pagina - Persoonlijk - Microsoft​ Edge

How can i import a value from energy dashboard to a custom sensor? I’ve added my home wizard p1 meter to energy dashboard. This gives me the daily imported and exported values of my energy in the house. But how can i use this exact value in a custom template in yaml so i can create other sensors that will be using this value?

Using this for import and modify for export…

All used templates browse a bit up

  - platform: template
    sensors:
      energy_import_total_dagelijks_kwh:
        friendly_name: 'kWh vandaag dal + normaal'
        value_template: "{{ (states('sensor.energy_import_t1_dagelijks')|float + states('sensor.energy_import_t2_dagelijks')|float)|round(2) }}"
        unit_of_measurement: "kWh"

Isn’t this the old template layout?
My sensor layouts are like you can see in the pictures. I’ve tried to adjust your layout to mine but i’m getting errors . Do you know how to adjust it?

already running this for a couple of years, guess need to look in updating this…
can’t help in the new format…

Hallo,
Ik ben nog nieuw met homeassistant, Nu wil ik de homewizard p1 toevoegen en vraagt homeassistant om het ip adres van de p1 meter.
Zodra ik deze invul (zit verbonden met een tp link m5 mesh) dan zegt hij dat het niet klopt.
Denk ik te makkelijk en zie ik iets over het hoofd?

HA should be able to detect the P1 automaticly

thanks for replying, only its not happening, (Allready activated the API in the app.) Apps works fine btw

It’s Asking for IP from the wizard p1, so i looked it up in the DECO M5 app. only HA says its wrong IP or not accesable

I’ve recently updated my HA version and now have more info coming from the HomeWizard P1 meter.
I also have a digital watermeter (Pidpa, Belgium) and I can see the info in the API, but not in HomeAssistant.

Is this something that can be added?

@exCite, I am waiting for a review in this PR. Maybe you can take a quick look and leave some comments. https://github.com/home-assistant/core/pull/86386

I have the latest versions, But i can only see the Peak demand for the current month and not the average for current quarter. Or will it appear when 3 months are over?

Another Question, how can i store the monthly peak demand in a sensor for every month. So i can see a easy history of the peak demands.

Quarter, as in 15 minutes. Represented as “ Active average demand”.

Sorry for any confusion.

ok i got it.

Now i have created a nice Dashboard for home assistant (only useful for belgium users):
image

How is it done
This is the first time ever i share some code here. so no idea if this is readable

1. Edit the P1 sensors:

  • Edit the sensor sensor.energy_active_average_demand from W to kWh
  • Edit the sensor sensor.energy_peak_demand_current_month from W to kWh

2. Make number helpers for the 12 months of the year:

example:

3. Add a max peak number helper:

Example:

4. Create a sensor for the maximum piek

      max_peak:
        friendly_name: Maximum piek 
        unit_of_measurement: "kWh"
        device_class: energy
        value_template: >
          {% set peak = ((states.sensor.energy_active_average_demand.state | float(default=0)) * 4) %}
          {% set max_peak = (states.input_number.max_peak_2.state | float(default=0)) %}
          {% macro max(X, Y) -%} {{X|float if X|float > Y|float else Y|float }} {%- endmacro %}
          {{ max(max_peak, peak) }}

5. Create a sensor for the Gemiddelde jaarpiek

      year_peak:
        friendly_name: Gemiddelde jaarpiek
        unit_of_measurement: "W"
        device_class: power
        value_template: >
          {{ (( states('input_number.january_peak_2') | float(default=0) +
                states('input_number.february_peak_2') | float(default=0) +
                states('input_number.march_peak_2') | float(default=0) +
                states('input_number.april_peak_2') | float(default=0) +
                states('input_number.may_peak_2') | float(default=0) +
                states('input_number.june_peak_2') | float(default=0) +
                states('input_number.july_peak_2') | float(default=0) +
                states('input_number.august_peak_2') | float(default=0) +
                states('input_number.september_peak_2') | float(default=0) +
                states('input_number.october_peak_2') | float(default=0) +
                states('input_number.november_peak_2') | float(default=0) +
                states('input_number.december_peak_2') | float(default=0) ) / 12) | round(2)
          }}

6. Create an Automation for the Maximum maandpiek

alias: Maximum maandpiek
description: ""
trigger:
  - platform: template
    value_template: "{{ (as_timestamp(now()))|timestamp_custom('%d', true) | int == 1 }}"
condition: []
action:
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ (as_timestamp(now()))|timestamp_custom('%m', true)|int == 2 }}"
        sequence:
          - service: input_number.set_value
            target:
              entity_id: input_number.january_peak_2
            data:
              value: >
                {% if states("sensor.max_peak") | float(default=0)>
                states("input_number.january_peak_2") | float(default=0) %}
                  {{ states("sensor.max_peak") }}
                {% else %}
                  2.5
                {% endif %}
          - delay:
              seconds: 5
          - service: input_number.set_value
            data:
              value: 0.1
            target:
              entity_id: input_number.max_peak_2
          - delay:
              minutes: 1
          - service: input_number.set_value
            target:
              entity_id: input_number.february_peak_2
            data:
              value: 2.5
      - conditions:
          - condition: template
            value_template: "{{ (as_timestamp(now()))|timestamp_custom('%m', true)|int == 3 }}"
        sequence:
          - service: input_number.set_value
            target:
              entity_id: input_number.february_peak_2
            data:
              value: >
                {% if states("sensor.max_peak") | float(default=0)>
                states("input_number.february_peak_2") | float(default=0) %}
                  {{ states("sensor.max_peak") }}
                {% else %}
                  2.5
                {% endif %}
          - delay:
              seconds: 5
          - service: input_number.set_value
            target:
              entity_id: input_number.max_peak_2
            data:
              value: 0.1
          - delay:
              minutes: 1
          - service: input_number.set_value
            target:
              entity_id: input_number.march_peak_2
            data:
              value: 2.5
      - conditions:
          - condition: template
            value_template: "{{ (as_timestamp(now()))|timestamp_custom('%m', true)|int == 4 }}"
        sequence:
          - service: input_number.set_value
            target:
              entity_id: input_number.march_peak_2
            data:
              value: >
                {% if states("sensor.max_peak") | float(default=0)>
                states("input_number.march_peak_2") | float(default=0) %}
                  {{ states("sensor.max_peak") }}
                {% else %}
                  2.5
                {% endif %}
          - delay:
              seconds: 5
          - service: input_number.set_value
            target:
              entity_id: input_number.max_peak_2
            data:
              value: 0.1
          - delay:
              minutes: 1
          - service: input_number.set_value
            target:
              entity_id: input_number.april_peak_2
            data:
              value: 2.5
      - conditions:
          - condition: template
            value_template: "{{ (as_timestamp(now()))|timestamp_custom('%m', true)|int == 5 }}"
        sequence:
          - service: input_number.set_value
            target:
              entity_id: input_number.april_peak_2
            data:
              value: >
                {% if states("sensor.max_peak") | float(default=0)>
                states("input_number.april_peak_2") | float(default=0) %}
                  {{ states("sensor.max_peak") }}
                {% else %}
                  2.5
                {% endif %}
          - delay:
              seconds: 5
          - service: input_number.set_value
            target:
              entity_id: input_number.max_peak_2
            data:
              value: 0.1
          - delay:
              minutes: 1
          - service: input_number.set_value
            target:
              entity_id: input_number.may_peak_2
            data:
              value: 2.5
      - conditions:
          - condition: template
            value_template: "{{ (as_timestamp(now()))|timestamp_custom('%m', true)|int == 6 }}"
        sequence:
          - service: input_number.set_value
            target:
              entity_id: input_number.may_peak_2
            data:
              value: >
                {% if states("sensor.max_peak") | float(default=0)>
                states("input_number.may_peak_2") | float(default=0) %}
                  {{ states("sensor.max_peak") }}
                {% else %}
                  2.5
                {% endif %}
          - delay:
              seconds: 5
          - service: input_number.set_value
            target:
              entity_id: input_number.max_peak_2
            data:
              value: 0.1
          - delay:
              minutes: 1
          - service: input_number.set_value
            target:
              entity_id: input_number.june_peak_2
            data:
              value: 2.5
      - conditions:
          - condition: template
            value_template: "{{ (as_timestamp(now()))|timestamp_custom('%m', true)|int == 7 }}"
        sequence:
          - service: input_number.set_value
            target:
              entity_id: input_number.june_peak_2
            data:
              value: >
                {% if states("sensor.max_peak_2") | float(default=0)>
                states("input_number.june_peak_2") | float(default=0) %}
                  {{ states("sensor.max_peak_2") }}
                {% else %}
                  2.5
                {% endif %}
          - delay:
              seconds: 5
          - service: input_number.set_value
            target:
              entity_id: input_number.max_peak_2
            data:
              value: 0.1
          - delay:
              minutes: 1
          - service: input_number.set_value
            target:
              entity_id: input_number.july_peak_2
            data:
              value: 2.5
      - conditions:
          - condition: template
            value_template: "{{ (as_timestamp(now()))|timestamp_custom('%m', true)|int == 8 }}"
        sequence:
          - service: input_number.set_value
            target:
              entity_id: input_number.july_peak_2
            data:
              value: >
                {% if states("sensor.max_peak_2") | float(default=0)>
                states("input_number.july_peak_2") | float(default=0) %}
                  {{ states("sensor.max_peak_2") }}
                {% else %}
                  2.5
                {% endif %}
          - delay:
              seconds: 5
          - service: input_number.set_value
            target:
              entity_id: input_number.max_peak_2
            data:
              value: 0.1
          - delay:
              minutes: 1
          - service: input_number.set_value
            target:
              entity_id: input_number.august_peak_2
            data:
              value: 2.5
      - conditions:
          - condition: template
            value_template: "{{ (as_timestamp(now()))|timestamp_custom('%m', true)|int == 9 }}"
        sequence:
          - service: input_number.set_value
            target:
              entity_id: input_number.august_peak_2
            data:
              value: >
                {% if states("sensor.max_peak_2") | float(default=0)>
                states("input_number.august_peak_2") | float(default=0) %}
                  {{ states("sensor.max_peak_2") }}
                {% else %}
                  2.5
                {% endif %}
          - delay:
              seconds: 5
          - service: input_number.set_value
            target:
              entity_id: input_number.max_peak_2
            data:
              value: 0.1
          - delay:
              minutes: 1
          - service: input_number.set_value
            target:
              entity_id: input_number.september_peak_2
            data:
              value: 2.5
      - conditions:
          - condition: template
            value_template: "{{ (as_timestamp(now()))|timestamp_custom('%m', true)|int == 10 }}"
        sequence:
          - service: input_number.set_value
            target:
              entity_id: input_number.september_peak_2
            data:
              value: >
                {% if states("sensor.max_peak_2") | float(default=0)>
                states("input_number.september_peak_2") | float(default=0) %}
                  {{ states("sensor.max_peak_2") }}
                {% else %}
                  2.5
                {% endif %}
          - delay:
              seconds: 5
          - service: input_number.set_value
            target:
              entity_id: input_number.max_peak_2
            data:
              value: 0.1
          - delay:
              minutes: 1
          - service: input_number.set_value
            target:
              entity_id: input_number.october_peak_2
            data:
              value: 2.5
      - conditions:
          - condition: template
            value_template: "{{ (as_timestamp(now()))|timestamp_custom('%m', true)|int == 11 }}"
        sequence:
          - service: input_number.set_value
            target:
              entity_id: input_number.october_peak_2
            data:
              value: >
                {% if states("sensor.max_peak_2") | float(default=0)>
                states("input_number.october_peak_2") | float(default=0) %}
                  {{ states("sensor.max_peak_2") }}
                {% else %}
                  2.5
                {% endif %}
          - delay:
              seconds: 5
          - service: input_number.set_value
            target:
              entity_id: input_number.max_peak_2
            data:
              value: 0.1
          - delay:
              minutes: 1
          - service: input_number.set_value
            target:
              entity_id: input_number.november_peak_2
            data:
              value: 2.5
      - conditions:
          - condition: template
            value_template: "{{ (as_timestamp(now()))|timestamp_custom('%m', true)|int == 12 }}"
        sequence:
          - service: input_number.set_value
            target:
              entity_id: input_number.november_peak_2
            data:
              value: >
                {% if states("sensor.max_peak_2") | float(default=0)>
                states("input_number.november_peak_2") | float(default=0) %}
                  {{ states("sensor.max_peak_2") }}
                {% else %}
                  2.5
                {% endif %}
          - delay:
              seconds: 5
          - service: input_number.set_value
            target:
              entity_id: input_number.max_peak_2
            data:
              value: 0.1
          - delay:
              minutes: 1
          - service: input_number.set_value
            target:
              entity_id: input_number.december_peak_2
            data:
              value: 2.5
    default:
      - service: input_number.set_value
        target:
          entity_id: input_number.december_peak_2
        data:
          value: >
            {% if states("sensor.max_peak_2") | float(default=0)>
            states("input_number.december_peak_2") | float(default=0) %}
              {{ states("sensor.max_peak_2") }}
            {% else %}
              2.5
            {% endif %}
      - delay:
          seconds: 5
      - service: input_number.set_value
        target:
          entity_id: input_number.max_peak_2
        data:
          value: 0.1
      - delay:
          minutes: 1
      - service: input_number.set_value
        target:
          entity_id: input_number.january_peak_2
        data:
          value: 2.5
mode: single

7. Create a automation for the Maximum piek:

alias: Maximum piek 2
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.max_peak
condition:
  - condition: template
    value_template: >
      {{  states("sensor.max_peak") | float(default=0)>
      states("input_number.max_peak_2") | float(default=0)}}
action:
  - service: input_number.set_value
    target:
      entity_id: input_number.max_peak_2
    data:
      value: |
        {{ states("sensor.max_peak") | float(default=0)}}
mode: parallel

8. Make your Dashboard (example):

type: vertical-stack
cards:
  - type: horizontal-stack
    cards:
      - type: custom:button-card
        entity: input_number.january_peak_2
        name: Jan
        show_state: true
        show_icon: false
      - type: custom:button-card
        entity: input_number.february_peak_2
        name: Feb
        show_state: true
        show_icon: false
      - type: custom:button-card
        entity: input_number.march_peak_2
        name: Mar
        show_state: true
        show_icon: false
      - type: custom:button-card
        entity: input_number.april_peak_2
        name: Apr
        show_state: true
        show_icon: false
      - type: custom:button-card
        entity: input_number.may_peak_2
        name: May
        show_state: true
        show_icon: false
      - type: custom:button-card
        entity: input_number.june_peak_2
        name: Jun
        show_state: true
        show_icon: false
  - type: horizontal-stack
    cards:
      - type: custom:button-card
        entity: input_number.july_peak_2
        name: Jul
        show_state: true
        show_icon: false
      - type: custom:button-card
        entity: input_number.august_peak_2
        name: Aug
        show_state: true
        show_icon: false
      - type: custom:button-card
        entity: input_number.september_peak_2
        name: Sep
        show_state: true
        show_icon: false
      - type: custom:button-card
        entity: input_number.october_peak_2
        name: Oct
        show_state: true
        show_icon: false
      - type: custom:button-card
        entity: input_number.november_peak_2
        name: Nov
        show_state: true
        show_icon: false
      - type: custom:button-card
        entity: input_number.december_peak_2
        name: Dec
        show_state: true
        show_icon: false
  - type: horizontal-stack
    cards:
      - type: gauge
        entity: sensor.year_peak
        min: 2.5
        needle: true
        severity:
          green: 2.5
          yellow: 3
          red: 4
        name: Gemiddelde jaarpiek
        unit: kWh
        max: 5
      - type: gauge
        entity: sensor.max_peak
        min: 2.5
        max: 5
        needle: true
        severity:
          green: 2.5
          yellow: 3
          red: 4
        name: Max Maandkwartierpiek
        unit: kWh

4 Likes

@sn33ky I’d love to use this, this way I don’t need to login to the Fluvius website.

i edited my post to give you the opportunity to use it yourself. If the code can be improved i would love to hear it.