HomeWizard Wi-Fi Energy Socket plugin

Moderator: leecollings

Post Reply
Eraser
Posts: 24
Joined: Friday 13 January 2017 9:24
Target OS: Windows
Domoticz version: 3.8153
Contact:

HomeWizard Wi-Fi Energy Socket plugin

Post by Eraser »

For those who need it I wrote a python plugin for the HomeWizard Wi-Fi Energy Socket. You can get it over here on Github.

The plugin creates 3 devices:
- An energy meter for current power usage and total energy consumption.
- A switch to toggle the socket on and off.
- A wifi signal strength meter that shows the signal strength for the energy socket device.

Use this Domoticz wiki page for installation instructions.
Bramz
Posts: 8
Joined: Wednesday 01 October 2014 14:28
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: NL
Contact:

Re: HomeWizard Wi-Fi Energy Socket plugin

Post by Bramz »

@Eraser - Thanks a lot for making this plugin available.
I installed it and it works well with my HomeWizard Energy socket apart from one issue.
After a few days running correctly the plugin stops working for some reason.
When I restart the domoticz service the plugin also resumes working for a number of days until again it stops.

Any suggestion how to find out why this happens?
Is there a log that I could look at?
RPi B, RFXtrx 433e, KaKu switches, P1-Smart Meter cable v2, CO2 sensor, 1Wire-WirelessMultiSensor, SBFspot/PV-output
robertbrink
Posts: 1
Joined: Monday 27 May 2024 8:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: HomeWizard Wi-Fi Energy Socket plugin

Post by robertbrink »

There is new firmware (4.08) for the Energy Socket, providing even more information, including voltage, which comes in handy if your energy meter (P1) doesn't support that and you want to monitor your solar panels during a sunny day, because when the voltage exceeds 253V, inverters will cut out. I have set the alarm to 250V.

/api/v1/data now gets you the following JSON data:

Code: Select all

{
  "wifi_ssid": "[your SSID]",
  "wifi_strength": 86,
  "total_power_import_kwh": 62.714,
  "total_power_import_t1_kwh": 62.714,
  "total_power_export_kwh": 0,
  "total_power_export_t1_kwh": 0,
  "active_power_w": 0,
  "active_power_l1_w": 0,
  "active_voltage_v": 234.898,
  "active_current_a": 0,
  "active_frequency_hz": 50.016
}
I have experimented with plugin.py to create voltage, current and frequency devices. Voltage and current work, albeit rounded to an integer, could not get the float to work, somehow the decimal point gets lost in translation. But frequency isn't stable, it will eventually create a problem log that the device already exists in Domoticz (though it will keep measuring).

Code snippets with the changes:

Code: Select all

    #Homewizard Energy Socket variables
    wifi_strength = -1              #: [Number] De sterkte van het Wi-Fi signaal in %
    total_power_import_t1_kwh = -1  #: [Number] De stroomafname meterstand voor tarief 1 in kWh
    total_power_export_t1_kwh = -1  #: [Number] De stroomteruglevering meterstand voor tarief 1 in kWh
    active_power_w = -1             #: [Number] Het huidig gebruik van alle fases gecombineerd in Watt
    active_power_l1_w = -1          #: [Number] Het huidig gebruik voor fase 1 in Watt (indien van toepassing)
    active_voltage_v = -1           #: [Number] De huidige netspanning (alleen met firmware 4.08 of hoger)
    active_current_a = -1           #: [Number] De huidige stroom (alleen met firmware 4.08 of hoger)
#    active_frequency_hz = -1        #: [Number] De huidige netfrequentie (alleen met firmware 4.08 of hoger)
    
    #Calculated variables
    total_power = 0                 #: Het totale gecombineerde vermogen.
    import_active_power_w = 0       #: Het huidig vermogen wat momenteel van het net wordt geimporteerd.
    export_active_power_w = 0       #: Het huidig vermogen wat momenteel naar het net wordt geexporteerd.
    
    #Device ID's
    active_power_id = 101
    switch_id = 130
    wifi_signal_id = 140
    voltage_id = 150
    current_id = 151
#    frequency_id = 152

Code: Select all

   def onMessage(self, Data, Status, Extra):
        if ( Extra == "data" ):
            try:
                Domoticz.Debug("Reading values from data")
                
                self.wifi_strength = Data['wifi_strength']
                self.total_power_import_t1_kwh = int(Data['total_power_import_t1_kwh'] * 1000)
                self.total_power_export_t1_kwh = int(Data['total_power_export_t1_kwh'] * 1000)
                self.active_power_w = int(Data['active_power_w'])
                self.active_voltage_v = int(Data['active_voltage_v'])
                self.active_current_a = int(Data['active_current_a'])
#                self.active_frequency_hz = int(Data['active_frequency_hz'])

Code: Select all

               try:
                    if ( self.voltage_id not in Devices ):
                        Domoticz.Device(Name="Voltage",  Unit=self.voltage_id, Type=243, Subtype=8).Create()
                        
                    UpdateDevice(self.voltage_id, 0, numStr(self.active_voltage_v), True)
                except:
                    Domoticz.Error("Failed to update device id " + str(self.voltage_id))

                try:
                    if ( self.current_id not in Devices ):
                        Domoticz.Device(Name="Current",  Unit=self.current_id, Type=243, Subtype=23).Create()
                        
                    UpdateDevice(self.current_id, 0, numStr(self.active_current_a), True)
                except:
                    Domoticz.Error("Failed to update device id " + str(self.current_id))

#                Dit werkt nog niet goed, er verschijnt een foutmelding Error: Energy Socket: Device creation failed, Hardware/Unit combination (8:153) already exists in Domoticz. Terwijl er geen ander device is met id 153.

#                try:
#                    if ( self.active_frequency_hz not in Devices ):
#                        Domoticz.Device(Name="Frequency",  Unit=self.frequency_id, Type=243, Subtype=31).Create()
#                        
#                    UpdateDevice(self.frequency_id, 0, numStr(self.active_frequency_hz), True)
#                except:
#                    Domoticz.Error("Failed to update device id " + str(self.frequency_id))
Though I have been working in IT for decades, this is is my first attempt in writing Python code and modifying Domoticz plugins, so some things will be probably be sub-optimal. :D After I have changed plugin.py, I have deleted the Homewizard Energy Socket hardware in Domoticz, restarted Domoticz and subsequently added the hardware. It took a minute for the devices to appear but after that it was working flawlessly, I can now monitor the voltage.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests