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.

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.