question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Kwh meter for power switch not working properly.

See original GitHub issue

Issue description Due to recent changes in Domoticz the sValue now requires two values separated by “;” eg. sValue = power;energy I made a workaround in devices/sensor/kwh.py by adding the missing value to the return string when only one value in array. Also found that the value_key array doesn’t work, or not holding the correct variable/string for getting power and energy reading, or it might be the for loop that doesn’t work correctly. Any way, after several tries modifying for loop etc, I still couldn’t get it to work, so made a workaround to get power and energy from device. My device is Develco SPLZB-131 power plug.

Attached code is the modified code that works for power and energy return in sValue.

import Domoticz
from devices.device import Device


class KwhSensor(Device):
    def __init__(self, devices, alias, value_key, device_name_suffix=''):
        super().__init__(devices, alias, ';'.join(value_key), device_name_suffix)
        self.value_keys = ['power', 'energy'] #value_key Added static keys for array
        self.energy_multiplier = 1000
    
    def create_device(self, unit, device_id, device_name):
        options = {}
        options['EnergyMeterMode'] = '1'

        return Domoticz.Device(Unit=unit, DeviceID=device_id, Name=device_name, TypeName="kWh", Options=options).Create()

    def get_message_value(self, message):
        value = {} #[] #added

        for item in self.value_keys:
            if item in message.raw: # removed item [not]
                #return None
                value[item] = message.raw[item] #added
            #value.append(message.raw[item])

        return value if len(value) > 0 else None

    def get_numeric_value(self, value, device):
        return 0

    def get_string_value(self, value, device):
        if 'energy' in value: #len(value) == 2: added static comparison due to changes in for loop
            return str(value['power']) + ";" + str(value['energy'] * self.energy_multiplier)
            #return str(value[0]) + ";" + str(value[1] * self.energy_multiplier)
        else:
            return str(value['power']) + ";" + str(0) #Added required 2´nd value to domoticz
            #return str(value[0])

Additional information Zigbee2MQTT version: v.1.18.1 (ConBee2/RaspBee2 0x264a0700) Python version: 3.7.3 (default, Jul 25 2020, 13:03:44) [GCC 8.3.0] Domoticz version: V2020.2 build 13091 Plugin version: 3.0 (latest)

Could you please check and fix 😃 thanks

br lwalbert

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:40 (19 by maintainers)

github_iconTop GitHub Comments

2reactions
mvzutcommented, Mar 28, 2021

I have been experimenting a bit more, and like @awalsum suggested, the problem is probably related to the “power_outage_memory” field in the MQTT messages! After re-pairing my plugs these fields are not present in the messages anymore, whereas these were previously there (see my earlier screenshot of the log).

I actually need this setting, one of the plugs is monitoring the energy use of my aquarium, so this plug should always go on after a power outage. Therefore I set this memory setting to “On” again via the Zigbee2MQTT web configuration, but immediately afterwards the power readings stopped again in Domoticz!

Can it be that the plugin checks for the MQTT field with the word “power” in the title, but then accidentally finds the “power_outage_memory” field? That would explain why I got weird values like “1, 10”.

1reaction
awalsumcommented, Mar 27, 2021

Reconfiguring “Kelder ventilatie” through the frontend solved the problems with this plug. All values are updated now and I am able to switch it on and off. Not so much luck with the other plugs however.

I’m not at home at the moment so can’t physically reach the plugs. I’m going to try and delete the plug that don’t work completely from Domoticz and re-pair them, probably tomorrow or Monday. See if that fixes them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Energy Meter Repair - YouTube
for 5PCBs - order with coupon code: JLCPCBcomAny questions about JLCPCB or ordering, pls email support@jlcpcb.comWhat's wrong with this ...
Read more >
How To Reset Electrical Meter | Black Lion HVAC in Washington
Track your home's energy usage more accurately by resetting your electrical meter. Learn how to do this by following these steps.
Read more >
Under what circumstances can a digital electricity meter stop ...
There are some reasons for meter isn't working or stop working : 1. ... Meter tampering is theft of electricity from the power...
Read more >
Common smart meter problems and solutions - OVO Energy
Smart meter problems are usually simple to diagnose and fix. Here's a guide to the most common issues, and how you can solve...
Read more >
Troubleshooting checks - PM5300 - Schneider Electric
Check power meter voltage input terminals (1, 2, 3, 4) to verify that adequate voltage is present. Check that all CTs and VTs...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found