Energy Consumed

Hello,

I have a zigbee 3 phase inline power meter installed, I have a problem that the current energy consumed isn’t the actual consumed energy that is reported to the energy providers meter… the meter came before the zigbee meter… is there any way of updating the state of the meter from 100 that’s currently used to 400 that is on the meter (example) ? I checked via DB if I can change it, I can but that’s one time and the next time it’ll just pull the info from the meter again and will not match the main power meter…


{
    "ac_frequency": 49.99,
    "current": 0.23,
    "energy": 100, > Change this to 400
    "linkquality": 255,
    "power": 306,
    "power_factor": 76.9,
    "produced_energy": 0,
    "state": "ON",
    "voltage": 237.6
}

You may have more success getting help if you share more information about your setup.

  1. Make model and firmware of your zigbee device
  2. Are you on Zigbee2MQTT or ZHA or ???
  3. More details on this attribute, is this a daily value that rolls over at time, or a since meter installed value?

Good hunting!

Hi David! Thanks for your respone!

Friendly name - PowerMeter
Description
Last seen - N/A
Availability - Disabled
Device type - Router
Zigbee Model - TS0601
Zigbee Manufacturer - _TZE200_bkkmqmyo
Description - Single phase DIN-rail energy meter with switch function
Support status - Supported

IEEE Address - 0x943469fffec954e8
Network address - 0x4DE0
Manufacturer - Hiking
Model DDS238-2
Power Interview completed - True

I am setup with Zigbee2MQTT, reports correctly (mostly) unfortunately it doesn’t pickup the configurations entirely, not sure if it has everything exposed.

The attribute will change multiple times a day based on kWh usage. I believe it polls every 30secons or so.

I don’t know if there is an option to write to the device (I somehow doubt it) so maybe it would be simpler to just change the information it reports back from value to value + 300 kwh or something like that…

Not sure if this is your model or not, but if it is … ‘can’t reset to zero’ not a good sign here :unamused:

I think there should be a way to create some type of ‘template’ sensor in Home Assistant that will allow you to apply some type of ‘offset’ to the value coming in and expose this as a new sensor. I’ve not done this, but do some searching and maybe a new query here on this forum. There are some real gurus that can advise on tools to tweak sensors here. Good hunting!

https://www.aliexpress.us/item/2251832625751246.html?gatewayAdapt=glo2usa4itemAdapt

In thinking a bit more, I kind of have done things to modify incoming sensor values. Here is an example that might give you are start. This is a zigbee2mqtt temperature sensor that the temperature value comes in as degrees C and being a yank I have to have degrees F :wink:

your JSON attribute is value_json.energy I think. And your value template might something like:

value_template: "{{ (value_json.energy | float(0) + 400.0 ) | round(1) }}"

I’m making a big :peach: assumption that you do not need a variable offset based on time or something, if so then you need help from some folks with a higher pay grade.

# mqtt sensors
sensor:

  - name: "Mailbox Temperature"
    device_class: temperature
    unique_id: "0x00158d0009ee3f7a-mailbox-temperature"
    expire_after: 3600
    state_topic: "zigbee2mqtt/0x00158d0009ee3f7a"
    value_template: "{{ (value_json.device_temperature | float(0) * 1.8 + 32 ) | round(1) }}"
    unit_of_measurement: "°F"
    availability_topic: zigbee2mqtt/0x00158d0009ee3f7a/availability
    json_attributes_topic: "zigbee2mqtt/0x00158d0009ee3f7a"

Honestly I thought as much, and that’s the difficulty in this, that for this to make sense for me I would want the sensor to reflect realistic mai meter usage (or what it says it should be). It’s not as much resetting to zero as changing it’s value to something else… I don’t know how the vendor didn’t think of this…

Offset was what I was thinking… just not sure where the offset would be…

I don’t know if it would be energy since energy is picking up the values from the 3 phase meter… but I do think this is the way to go, a good direction. No need for anything like time based offset, just an offset on what it’s reading

cheers for the help

I found something that may do the trick

1 Like

Just an update.

Thanks David, the direction you went with float(0) + count was the simplest. and it’s doing exactly what I wanted… well kind of but it does the job… :slight_smile: thanks a lot

  sensors:
    - name: MainEnergyMeter
      unit_of_measurement: "kWh"
      device_class: energy  
      state_class: MainEnergyMeter
      state: >-
        {{ (states('sensor.energymeter') | float(0) + 6500 ) | round(0) }}

I also confirmed, that it is not possible to write to the meter, and no meter allows for this… which is in my opinion silly since it would make sense to have the same reading on both meters… oh well.

Thanks David! this helped me a lot and I am not a little smarter with HA potential

For reference for anyone looking at how to create the sensor, this is the easiest option.