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 %}
1 Like

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:

1 Like

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…

this sensors work as expected, only problem from my side is that am not able to integrate them in the energy pannel…
any ideas?

For anyone interested, I have the same problem. I took the watts reading what seems to be correct, and then used Integration - Riemann sum integral - Home Assistant to add it to the energy config. Here is my code:

sensor:
  - platform: integration
    source: sensor.wasmachine_electric_consumption_w
    name: Stroommeter wasmachine
    method: left
    round: 2
    unit_prefix: k
2 Likes

Sorry, but I am a total newbe and have to find out where and how to fit this in.
But has anyone found out why this happens overnight? I have 4 new plugs, all with firmware 2.23.0, and when I add them all seems to work well, but when you look at it the following morning, there a re negative values, and always -21474836.47. Plugs with other firmware work without trouble, it is only firmware version 2.23.0

Sorry to say, but this is a manufacturing error that is not fixed. You can use HA to fix those measurements, but the hardware (and thus the integration) will always remain as is.

I understand. I have a discussion with the AliExpres Coolcam Official Store (I bought all my plugs from them) and explained that plugs <> 2.23.0 do work properly. They answered “hello, for the firmware version. it is newest from our manufacturer.there are no 2.23.0 or 3.xx.x. Software version :02 17
hardware version:10”.
Strange thing is that, when I look at my devices in Home Assistant, I only have devices higher than 02 17. Highest version I have is 3.96.
Are there any others with higher versions than 02 17 (I assume 2.17)?

I have 2.23 and they have the issue. Is it possible to upgrade the FW to v3.x ?