Energy Consumption for Neo Coolcam Plug

I found in zwavejs2mqtt store the DSK value of my S2 Unauthenticated Plug.
So I exclude and add them again in S2 Authenticated with the this DSK. All is OK :-).

About reset I made this, it works great :

- id: 'neo_plug_2'
  alias: Neo Plug 2
  trigger:
    platform: numeric_state
    entity_id: sensor.prise_zwave_2_electric_consumption_kwh
    below: 0
  action:
  - service: zwave_js.reset_meter
    target:
      entity_id: sensor.prise_zwave_2_electric_consumption_kwh

I have also a Plug who does not report correctly the voltage, it’s between 12v and 233v. I think the electronic checking the voltage is out of service.

Beware that the plug is NOT always reporting negative values. from time to time it does report real values. I record the values in a database and ignore the negative values. At least it will give some indication of power consumption of the plug. Reset is not a fix for negative values, because soon after it will be negative again and you will have lost the real values and never know the power consumption through the plug. And actually if you would subtract the latest negative value from the previous negative you get the real power consumption in that interval.

After doing some further research, you can create a positive value (in another sensor) by adding 21,474,836.45 to the value. It will give you the real usage.

@pensionado I can confirm that adding this value seems to produce correct values - thanks!
Just out of curiosity - how did you calculate the exact value?

@ahochsteger I had one plug that occasionally had consumption, and as I indicated sometime the correct value was reported. So I reset the meter, created some consumption and waited for the negative value (and the correct one). This enabled me the calculate the correct factor and after confirming the value on some other plugs I found that to be the right value. I have now adjusted my program that records these values in an influxdb and saw that meter reporting is now consistent and correct.

1 Like

According to some bug fixes, the value to be corrected should be the equivalent of 0x7FFFFFFF

0x7FFFFFFF = 2147483647 ==> 21474836.47

This would prevent a decreasing total if you use a template sensor to correct this. I use this atm:

template:
  - sensor:
      - name: "Neo Plug Corrected Energy"
        unit_of_measurement: kWh
        device_class: energy
        state_class: total_increasing
        state: >-
          {% set value = states('sensor.neo_plug_energy') | float(0) %}
          {% set const = 21474836.47 %}
          {% if value < 0 %}{{ (value + const) | round(2) }}
          {% else %}{{ value }}
          {% endif %}
1 Like

when I try this I get errors after the config check. missing value_state and Invalid config for [sensor.template]: [state_class] is an invalid option for [sensor.template]. Check: sensor.template->sensors->neo_plug_bank->state_class. (See ?, line ?).

Can you share your exact yaml configuration?

This is what worked for me:

    neo_plug_fridge:
      friendly_name: "Neo fridge Corrected Energy"
      unit_of_measurement: kWh
      device_class: energy
      value_template: >-
        {% set value = states('sensor.fridge_kwh') | float(0) %}
        {% set const = 21474836.47 %}
        {% if value < 0 %}{{ (value + const) | round(2) }}
        {% else %}{{ value }}
        {% endif %}

I have made the same change to make it work.

It looks like you created a legacy templated binary sensor instead of the newer template component. Mine is the preferred configuration.

This is the difference:

# my sensor
template:
  - sensor:
      - name: "Neo Plug Corrected Energy"
        unit_of_measurement: kWh
        device_class: energy
        state_class: total_increasing
        state: >-
          {% set value = states('sensor.neo_plug_energy') | float(0) %}
          {% set const = 21474836.47 %}
          {% if value < 0 %}{{ (value + const) | round(2) }}
          {% else %}{{ value }}
          {% endif %}

# your sensor
sensor:
  - platform: template
    sensors:
      neo_plug_corrected_energy:
        friendly_name: "Neo Plug Corrected Energy"
        unit_of_measurement: kWh
        device_class: energy
        # state_class: total_increasing
        state: >-
          {% set value = states('sensor.neo_plug_energy') | float(0) %}
          {% set const = 21474836.47 %}
          {% if value < 0 %}{{ (value + const) | round(2) }}
          {% else %}{{ value }}
          {% endif %}

Read the documentation to see the differences:

I added into the sensor part not in binary_sensor part

there file list of the sensors.yaml file

supervisor-2021.12.2
core-2021.12.9
Home Assistant OS 7.1

in configuration file I have this line:

binary_sensor: !include package/includes/binary_sensors.yaml
sensor: !include package/includes//sensors.yaml

sensors.yaml

- platform: template
  sensors:
    kay_presence_homekit:
      friendly_name: "Kay"
      icon_template: mdi:network
      value_template: >-
        {% if is_state('input_boolean.kay_home_homekit','on') %} home 
        {% else %} not_home
        {% endif %}

    peter_presence_homekit:
      friendly_name: "Peter"
      icon_template: mdi:network
      value_template: >-
        {% if is_state('input_boolean.peter_home_homekit','on') %} home 
        {% else %} not_home
        {% endif %}

    neo_plug_imac:
      friendly_name: "Neo iMac Corrected Energy"
      unit_of_measurement: kWh
      device_class: energy
      value_template: >-
        {% set value = states('sensor.imac_kwh') | float(0) %}
        {% set const = 21474836.47 %}
        {% if value < 0 %}{{ (value + const) | round(2) }}
        {% else %}{{ value }}
        {% endif %}

If I add this directly in configuration.yaml file:

template:
  - sensor:
      - name: "Neo Plug Corrected Energy"
        unit_of_measurement: kWh
        device_class: energy
        state_class: total_increasing
        state: >-
          {% set value = states('sensor.neo_plug_energy') | float(0) %}
          {% set const = 21474836.47 %}
          {% if value < 0 %}{{ (value + const) | round(2) }}
          {% else %}{{ value }}
          {% endif %}

I get a error that template cant be there

My bad. I’ll update my example.

That’s strange, since it’s copied directly from my configuration. Are you sure there nothing else in the way?

Your original error suggests you’re using the legacy format:

missing value_state and Invalid config for [sensor.template]: [state_class] is an invalid option for [sensor.template]. Check: sensor.template->sensors->neo_plug_bank->state_class. (See ?, line ?).

In my configuration I have :slight_smile:
legacy_templates: false

Very strange isn’t it…