It was still pretty easy to read (especially with Google translate :)).
There's really only one API call supported, unless you want the raw data from the meter.
I took a stab at supporting it as a PowerMeter in Hubitat. Your version of the meter seems to update its power reading every 1 second, but I made the default refresh rate 10 seconds. The API document says not to poll any faster than twice per second.
Do you need access to any of the other readings, like cumulative power or instantaneous power for any of the individual phases? Those could be added using custom attributes, and they would be a good way for you to experiment with driver development if you are interested.
/*
*/
metadata
{
definition(name: "HomeWizard P1 Meter", namespace: "tomw", author: "tomw", importUrl: "")
{
capability "Initialize"
capability "PowerMeter"
capability "Refresh"
attribute "commStatus", "string"
}
}
preferences
{
section
{
input "ipAddress", "text", title: "IP address meter", required: true
input "refreshInterval", "number", title: "Refresh interval (seconds)", defaultValue: 10
input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: true
}
}
def logDebug(msg)
{
if (logEnable)
{
log.debug(msg)
}
}
def updated()
{
refresh()
}
def initialize()
{
sendEvent(name: "commStatus", value: "unknown")
sendEvent(name: "power", value: "unknown")
refresh()
}
def refresh()
{
unschedule()
try
{
def res = httpGetExec([uri: getBaseURI()], true)
sendEvent(name: "commStatus", value: "good")
sendEvent(name: "power", value: res?.active_power_w?.toInteger())
// schedule next refresh
runIn(refreshInterval.toInteger(), refresh)
}
catch (Exception e)
{
logDebug("refresh() failed: ${e.message}")
logDebug("run Refresh command re-start polling")
sendEvent(name: "commStatus", value: "error")
}
}
def getBaseURI()
{
return "http://${ipAddress}/api/v1/data"
}
def httpGetExec(params, throwToCaller = false)
{
logDebug("httpGetExec(${params})")
try
{
def result
httpGet(params)
{ resp ->
if (resp.data)
{
logDebug("resp.data = ${resp.data}")
result = resp.data
}
}
return result
}
catch (Exception e)
{
logDebug("httpGetExec() failed: ${e.message}")
if(throwToCaller)
{
throw(e)
}
}
}