Homewizard P1 meter binding update?

Hi all,

I just got a P1 meter from homewizard. I installed the binding and works great. But I see on API endpoints — HomeWizard Energy API documentation (homewizard-energy-api.readthedocs.io) that more parameters are available.
What is currently implemented is

<Request>
GET http://{IP address}/api/v1/data HTTP/1.1

<Response>
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: <length>

{
   "smr_version": 50,
   "meter_model": "ISKRA  2M550T-101",
   "wifi_ssid": "My Wi-Fi",
   "wifi_strength": 100,
   "total_power_import_t1_kwh": 10830.511,
   "total_power_import_t2_kwh": 2948.827,
   "total_power_export_t1_kwh": 1285.951,
   "total_power_export_t2_kwh": 2876.51,
   "active_power_w": -543,
   "active_power_l1_w": -676,
   "active_power_l2_w": 133,
   "active_power_l3_w": 0,
   "total_gas_m3": 2569.646,
   "gas_timestamp": 210606140010
}

But it appears that more data is available:

<Request>
GET http://{IP address}/api/v1/data HTTP/1.1

<Response>
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: <length>

{
   "wifi_ssid": "My Wi-Fi",
   "wifi_strength": 100,
   "smr_version": 50,
   "meter_model": "ISKRA  2M550T-101",
   "unique_id": "00112233445566778899AABBCCDDEEFF",
   "active_tariff": 2,
   "total_power_import_kwh": 13779.338,
   "total_power_import_t1_kwh": 10830.511,
   "total_power_import_t2_kwh": 2948.827,
   "total_power_export_kwh": 0,
   "total_power_export_t1_kwh": 0,
   "total_power_export_t2_kwh": 0,
   "active_power_w": -543,
   "active_power_l1_w": -676,
   "active_power_l2_w": 133,
   "active_power_l3_w": 0,
   "active_current_l1_a": -4,
   "active_current_l2_a": 2,
   "active_current_l3_a": 0,
   "voltage_sag_l1_count": 1,
   "voltage_sag_l2_count": 1,
   "voltage_sag_l3_count": 0,
   "voltage_swell_l1_count": 0,
   "voltage_swell_l2_count": 0,
   "voltage_swell_l3_count": 0,
   "any_power_fail_count": 4,
   "long_power_fail_count": 5,
   "total_gas_m3": 2569.646,
   "gas_timestamp": 210606140010,
   "gas_unique_id": "FFEEDDCCBBAA99887766554433221100",
   "active_power_average_w": 123.000,
   "montly_power_peak_w": 1111.000,
   "montly_power_peak_timestamp": 230101080010,
   "external": [
      {
         "unique_id": "FFEEDDCCBBAA99887766554433221100",
         "type": "gas_meter",
         "timestamp": 210606140010,
         "value": 2569.646,
         "unit": "m3"
      },
      {
         "unique_id": "ABCDEF0123456789ABCDEF0123456789",
         "type": "water_meter",
         "timestamp": 210606140015,
         "value": 123.456,
         "unit": "m3"
      }
   ]
}

Is anybody actually maintaining this binding? Or do i need to hack it myslef :wink:

Thanks,

Ramon

Hi,
i think the fastest way could be to use the http binding with a jsonpath transformation to get out anything you want if the binding does not support it yet.

2 Likes

Thx. Let me look into that!

I got it working:

Thing http:url:p1meter "Homewizard P1 meter" [
    baseURL="http://192.168.32.185/api/v1/data",
    refresh=5] {
        Channels:
		 Type string : wifi_ssid                 "Wifi SSID"     [ stateTransformation="JSONPATH:$.wifi_ssid", mode="READONLY"  ] 
		 Type number : wifi_strength             "Wifi strength" [ stateTransformation="JSONPATH:$.wifi_strength", mode="READONLY"  ]
		 Type number : smr_version               "SMR version" [ stateTransformation="JSONPATH:$.smr_version", mode="READONLY"  ]
		 Type string : meter_model               "Meter model"     [ stateTransformation="JSONPATH:$.meter_model", mode="READONLY"  ] 
		 Type string : unique_id                 "unique id"     [ stateTransformation="JSONPATH:$.unique_id", mode="READONLY"  ] 
		 Type number : active_tariff             "Active teriff" [ stateTransformation="JSONPATH:$.active_tariff", mode="READONLY"  ]
		 Type number : total_energy_import_total "Import total"  [ stateTransformation="JSONPATH:$.total_power_import_kwh", mode="READONLY"  ]
		 Type number : total_energy_import_t1    "Import T1"     [ stateTransformation="JSONPATH:$.total_power_import_t1_kwh", mode="READONLY"  ]
		 Type number : total_energy_import_t2    "Import T2"     [ stateTransformation="JSONPATH:$.total_power_import_t2_kwh", mode="READONLY"  ] 
		 Type number : total_energy_export_total "Export total"  [ stateTransformation="JSONPATH:$.total_power_export_kwh", mode="READONLY"  ]
		 Type number : total_energy_export_t1    "Export T1"     [ stateTransformation="JSONPATH:$.total_power_export_t1_kwh", mode="READONLY"  ] 
		 Type number : total_energy_export_t2    "Export T1"     [ stateTransformation="JSONPATH:$.total_power_export_t2_kwh", mode="READONLY"  ] 
		 Type number : active_power              "Power total"   [ stateTransformation="JSONPATH:$.active_power_w", mode="READONLY"  ] 
		 Type number : active_power_l1           "Power L1"      [ stateTransformation="JSONPATH:$.active_power_l1_w", mode="READONLY"  ] 
		 Type number : active_power_l2           "Power L2"      [ stateTransformation="JSONPATH:$.active_power_l2_w", mode="READONLY"  ] 
		 Type number : active_power_l3           "Power L3"      [ stateTransformation="JSONPATH:$.active_power_l3_w", mode="READONLY"  ] 
		 Type number : active_voltage_l1         "Voltage L1"    [ stateTransformation="JSONPATH:$.active_voltage_l1_v", mode="READONLY"  ] 
		 Type number : active_voltage_l2         "Voltage L2"    [ stateTransformation="JSONPATH:$.active_voltage_l2_v", mode="READONLY"  ] 
		 Type number : active_voltage_l3         "Voltage L3"    [ stateTransformation="JSONPATH:$.active_voltage_l3_v", mode="READONLY"  ] 
		 Type number : active_current_l1_a       "Current L1"    [ stateTransformation="JSONPATH:$.active_current_l1_a", mode="READONLY"  ] 
		 Type number : active_current_l2_a       "Current L2"    [ stateTransformation="JSONPATH:$.active_current_l2_a", mode="READONLY"  ] 
		 Type number : active_current_l3_a       "Current L3"    [ stateTransformation="JSONPATH:$.active_current_l3_a", mode="READONLY"  ] 
		 Type number : voltage_sag_l1_count      "Voltage sag L1 count"   [ stateTransformation="JSONPATH:$.voltage_sag_l1_count", mode="READONLY"  ] 
		 Type number : voltage_sag_l2_count      "Voltage sag L2 count"   [ stateTransformation="JSONPATH:$.voltage_sag_l2_count", mode="READONLY"  ] 
		 Type number : voltage_sag_l3_count      "Voltage sag L3 count"   [ stateTransformation="JSONPATH:$.voltage_sag_l3_count", mode="READONLY"  ] 
		 Type number : voltage_swell_l1_count    "Voltage swell L1 count" [ stateTransformation="JSONPATH:$.voltage_swell_l1_count", mode="READONLY"  ] 
		 Type number : voltage_swell_l2_count    "Voltage swell L2 count" [ stateTransformation="JSONPATH:$.voltage_swell_l2_count", mode="READONLY"  ] 
		 Type number : voltage_swell_l3_count    "Voltage swell L3 count" [ stateTransformation="JSONPATH:$.voltage_swell_l3_count", mode="READONLY"  ] 
		 Type number : any_power_fail_count      "Any power fail count"   [ stateTransformation="JSONPATH:$.any_power_fail_count", mode="READONLY"  ] 		 
		 Type number : long_power_fail_count     "Long power fail count"  [ stateTransformation="JSONPATH:$.long_power_fail_count", mode="READONLY"  ] 		 
		 Type number : total_gas                 "Gas total"     [ stateTransformation="JSONPATH:$.total_gas_m3", mode="READONLY"  ] 
		 Type string : gas_unique_id             "Gas ID"        [ stateTransformation="JSONPATH:$.gas_unique_id", mode="READONLY"  ] 
		 Type datetime : gas_timestamp           "Gas timestamp" [ stateTransformation="JSONPATH:$.gas_timestamp", mode="READONLY"  ]
} 

Thx again!

3 Likes

Hi,
I assume the information was already displayed when you manually accessed the api/v1/data URL?

Thanks.

yes!

I can confirm the API call method works quite well, Thanks for sharing.
In my case, I wanted to get access to the monthly power peak data, but the data was not available in the API call. A quick mail to Fluvius solved the problem: they uploaded the latest firmware to my smart meter. The P1 meter now provides the data.

One question though: the DateTime conversion is not standard ISO. Did you find an elegant way to get the data strings (e.g. in your example “YYMMDDhhmmss”) converted to standard Date Time?

to be honest I did not try, im not really storing that part, just to show it when it was last updated. One thing I did see with the http binding is that sometimes it gots stuck, even with a timeout. So in the end I replaced it with:

rule "watchdog for homewizard every 5 sec" when 
  Time cron "*/5 * * ? * * " then
   var headers = newHashMap();
		var result= sendHttpGetRequest("http://192.168.32.185/api/v1/data", headers, 60000) 
		if (result !== null) {
			if (transform("JSONPATH", "$.total_power_import_kwh", result) !== null) P1meterEnergy_Import_tot.postUpdate(  transform("JSONPATH", "$.total_power_import_kwh", result))
			if (transform("JSONPATH", "$.total_power_import_t1_kwh", result) !== null) P1meterEnergy_Import_T1.postUpdate(   transform("JSONPATH", "$.total_power_import_t1_kwh", result))
			if (transform("JSONPATH", "$.total_power_import_t2_kwh", result) !== null) P1meterEnergy_Import_T2.postUpdate(   transform("JSONPATH", "$.total_power_import_t2_kwh", result))
			if (transform("JSONPATH", "$.total_power_export_kwh", result) !== null) P1meterEnergy_Export_tot.postUpdate(   transform("JSONPATH", "$.total_power_export_kwh", result))
			if (transform("JSONPATH", "$.total_power_export_t1_kwh", result) !== null) P1meterEnergy_Export_T1.postUpdate(   transform("JSONPATH", "$.total_power_export_t1_kwh", result))
			if (transform("JSONPATH", "$.total_power_export_t2_kwh", result) !== null) P1meterEnergy_Export_T2.postUpdate(   transform("JSONPATH", "$.total_power_export_t2_kwh", result))
			if (transform("JSONPATH", "$.active_power_w", result) !== null) P1meterActive_Power.postUpdate( transform("JSONPATH", "$.active_power_w", result))
			if (transform("JSONPATH", "$.active_power_l1_w", result) !== null) P1meterActive_Power_L1.postUpdate(   transform("JSONPATH", "$.active_power_l1_w", result))
			if (transform("JSONPATH", "$.active_power_l2_w", result) !== null) P1meterActive_Power_L2.postUpdate(   transform("JSONPATH", "$.active_power_l2_w", result))   
			if (transform("JSONPATH", "$.active_power_l3_w", result) !== null) P1meterActive_Power_L3.postUpdate(   transform("JSONPATH", "$.active_power_l3_w", result))   
			if (transform("JSONPATH", "$.total_gas_m3", result) !== null) P1metertotal_gas.postUpdate(         transform("JSONPATH", "$.total_gas_m3", result))
			if (transform("JSONPATH", "$.gas_timestamp", result) !== null) P1meterGasLastUpdate.postUpdate(     transform("JSONPATH", "$.gas_timestamp", result)) 
			if (transform("JSONPATH", "$.wifi_ssid", result) !== null) P1meterwifi_ssid.postUpdate(         transform("JSONPATH", "$.wifi_ssid", result))    
			if (transform("JSONPATH", "$.wifi_strength", result) !== null) P1meterwifi_strength.postUpdate(     transform("JSONPATH", "$.wifi_strength", result))
			if (transform("JSONPATH", "$.active_tariff", result) !== null) P1meteractive_tariff.postUpdate(     transform("JSONPATH", "$.active_tariff", result))
			if (transform("JSONPATH", "$.active_voltage_l1_v", result) !== null) P1meteractive_voltage_l1.postUpdate( transform("JSONPATH", "$.active_voltage_l1_v", result)) 
			if (transform("JSONPATH", "$.active_voltage_l2_v", result) !== null) P1meteractive_voltage_l2.postUpdate( transform("JSONPATH", "$.active_voltage_l2_v", result)) 
			if (transform("JSONPATH", "$.active_voltage_l3_v", result) !== null) P1meteractive_voltage_l3.postUpdate( transform("JSONPATH", "$.active_voltage_l3_v", result)) 
			if (transform("JSONPATH", "$.active_current_l1_a", result) !== null) P1meteractive_current_l1.postUpdate( transform("JSONPATH", "$.active_current_l1_a", result)) 
			if (transform("JSONPATH", "$.active_current_l2_a", result) !== null) P1meteractive_current_l2.postUpdate( transform("JSONPATH", "$.active_current_l2_a", result)) 
			if (transform("JSONPATH", "$.active_current_l3_a", result) !== null) P1meteractive_current_l3.postUpdate( transform("JSONPATH", "$.active_current_l3_a", result)) 
			if (transform("JSONPATH", "$.voltage_sag_l1_count", result) !== null) P1metervoltage_sag_l1_count.postUpdate( transform("JSONPATH", "$.voltage_sag_l1_count", result))   
			if (transform("JSONPATH", "$.voltage_sag_l2_count", result) !== null) P1metervoltage_sag_l2_count.postUpdate( transform("JSONPATH", "$.voltage_sag_l2_count", result))   
			if (transform("JSONPATH", "$.voltage_sag_l3_count", result) !== null) P1metervoltage_sag_l3_count.postUpdate( transform("JSONPATH", "$.voltage_sag_l3_count", result))   
			if (transform("JSONPATH", "$.voltage_swell_l1_count", result) !== null) P1metervoltage_swell_l1_count.postUpdate( transform("JSONPATH", "$.voltage_swell_l1_count", result))
			if (transform("JSONPATH", "$.voltage_swell_l2_count", result) !== null) P1metervoltage_swell_l2_count.postUpdate( transform("JSONPATH", "$.voltage_swell_l2_count", result))
			if (transform("JSONPATH", "$.voltage_swell_l3_count", result) !== null) P1metervoltage_swell_l3_count.postUpdate( transform("JSONPATH", "$.voltage_swell_l3_count", result))
			if (transform("JSONPATH", "$.any_power_fail_count", result) !== null) P1meterany_power_fail_count.postUpdate(   transform("JSONPATH", "$.any_power_fail_count", result))
			if (transform("JSONPATH", "$.long_power_fail_count", result) !== null) P1meterlong_power_fail_count.postUpdate(  transform("JSONPATH", "$.long_power_fail_count", result))
			P1meterLastUpdate.postUpdate(new DateTimeType())
		}	
end

You can use the exact same items, just remove the channel from the definition.