home-assistant-toon_smartmeter
home-assistant-toon_smartmeter copied to clipboard
Toon_Smartswitch (Fibaro)
Cyberjunky, I've used your code to intergrate a Z-Wave Fibaro Wallplug to my Toon / Home Assistant setup.
Maybe this will be usefull for you?
https://github.com/Imperial-Guard/Toon_Smartswitch
Nice, I don't have any z-wave stuff anymore. I'm thinking of rewriting all toon_ modules using one python library and config_flow. But this needs time and it's working the way it is.
@Imperial-Guard Can you send me an example json string from your toon regarding these plugs?
@cyberjunky I'm using from the http://192.168.x.x/hdrv_zwave?action=getDevices.json :
'elecusageflowfib' which is the current electricity usage in W
'elecusagecntfib': which is the kWh which will be increment by each change.
Let me know if this is helpful for you.
@Imperial-Guard how does this work with multiple plugs? How to find them? Your code seems to address one, or is it me not looking correctly? Is it possible to post the whole output of http://192.168.x.x/hdrv_zwave?action=getDevices.json you can mask the uui and other private values.
I've just one of those switches, so most likely I've just set it up for just one.
See below getDevices.json hopefully this will help you
{"dev_settings_device": {"uuid": "xx", "name": "settings_device", "internalAddress": "settings_device", "type": "settings_device"}, "dev_3": {"uuid": "xx", "name": "Server", "internalAddress": "3", "type": "FGWP011", "supportsCrc": "0", "ccList": "72 86 70 85 8e 25 73 32 31 7a ef 25 32 31", "supportedCC": "72 86 70 85 8e 25 73 32 31 7a ef 25 32 31", "nodeFlags": [], "IsConnected": "1", "HealthValue": "10", "DeviceName": "Server", "TargetStatus": "1", "CurrentElectricityFlow": "27.80", "CurrentElectricityQuantity": "244430.00"}, "dev_4": {"uuid": "xx", "name": "HAE_METER_v2", "internalAddress": "4", "type": "HAE_METER_v2", "supportsCrc": "1", "ccList": "22 3c 3d 3e 56 60 70 72 7a 86 8b 73", "supportedCC": "22 3c 3d 3e 56 60 70 72 7a 86 8b 73", "nodeFlags": [], "IsConnected": "1", "HealthValue": "4", "DeviceName": "HAE_METER_v2", "CurrentSensorStatus": "UNKNOWN"}, "dev_4.1": {"uuid": "xx", "name": "HAE_METER_v2_1", "internalAddress": "4.1", "type": "HAE_METER_v2_1", "supportsCrc": "0", "ccList": "3c 3d 3e 72 86", "supportedCC": "3c 3d 3e 72 86", "nodeFlags": [], "CurrentSensorStatus": "OPERATIONAL", "CurrentGasFlow": "24.00", "CurrentGasQuantity": "7781505.00", "DeviceName": "HAE_METER_v2_1"}, "dev_4.2": {"uuid": "xx", "name": "HAE_METER_v2_2", "internalAddress": "4.2", "type": "HAE_METER_v2_2", "supportsCrc": "0", "ccList": "3c 3d 3e 72 86", "supportedCC": "3c 3d 3e 72 86", "nodeFlags": [], "CurrentSensorStatus": "UNKNOWN", "DeviceName": "HAE_METER_v2_2", "CurrentElectricityFlow": "NaN", "CurrentElectricityQuantity": "NaN"}, "dev_4.3": {"uuid": "xx", "name": "HAE_METER_v2_3", "internalAddress": "4.3", "type": "HAE_METER_v2_3", "supportsCrc": "0", "ccList": "3c 3d 3e 72 86", "supportedCC": "3c 3d 3e 72 86", "nodeFlags": [], "CurrentSensorStatus": "OPERATIONAL", "DeviceName": "HAE_METER_v2_3", "CurrentElectricityFlow": "0.00", "CurrentElectricityQuantity": "6301103.00"}, "dev_4.4": {"uuid": "xx", "name": "HAE_METER_v2_4", "internalAddress": "4.4", "type": "HAE_METER_v2_4", "supportsCrc": "0", "ccList": "3c 3d 3e 72 86", "supportedCC": "3c 3d 3e 72 86", "nodeFlags": [], "CurrentSensorStatus": "UNKNOWN", "DeviceName": "HAE_METER_v2_4", "CurrentElectricityFlow": "NaN", "CurrentElectricityQuantity": "NaN"}, "dev_4.5": {"uuid": "xx2", "name": "HAE_METER_v2_5", "internalAddress": "4.5", "type": "HAE_METER_v2_5", "supportsCrc": "0", "ccList": "3c 3d 3e 72 86", "supportedCC": "3c 3d 3e 72 86", "nodeFlags": [], "CurrentSensorStatus": "UNKNOWN", "DeviceName": "HAE_METER_v2_5", "CurrentElectricityFlow": "676.00", "CurrentElectricityQuantity": "7581144.00"}, "dev_4.6": {"uuid": "xx", "name": "HAE_METER_v2_6", "internalAddress": "4.6", "type": "HAE_METER_v2_6", "supportsCrc": "0", "ccList": "3c 3d 3e 72 86", "supportedCC": "3c 3d 3e 72 86", "nodeFlags": [], "CurrentSensorStatus": "UNKNOWN", "DeviceName": "HAE_METER_v2_6", "CurrentElectricityFlow": "NaN", "CurrentElectricityQuantity": "NaN"}}
Hi. I have two plugs and a smoke detector. Using this script which works great for power consumption values. Would be awesome to also be able to read the On/Off status of the plugs in addition to the power usage. Smoke alarm AlarmStatus and temperature could also be interesting. Hope this helps:
{"dev_settings_device": {"uuid": "xx", "name": "settings_device", "internalAddress": "settings_device", "type": "settings_device"}, "dev_6": {"uuid": "xx", "name": "Plug1", "internalAddress": "6", "type": "FGWP011", "supportsCrc": "0", "ccList": "72 86 70 85 8e 25 73 32 31 7a", "supportedCC": "72 86 70 85 8e 25 73 32 31 7a", "nodeFlags": [], "TargetStatus": "0", "CurrentElectricityFlow": "NaN", "CurrentElectricityQuantity": "967120.00", "IsConnected": "0", "HealthValue": "1", "DeviceName": "Plug1"}, "dev_7": {"uuid": "xx", "name": "Plug2", "internalAddress": "7", "type": "FGWP011", "supportsCrc": "0", "ccList": "72 86 70 85 8e 25 73 32 31 7a ef 25 32 31", "supportedCC": "72 86 70 85 8e 25 73 32 31 7a ef 25 32 31", "nodeFlags": [], "TargetStatus": "0", "CurrentElectricityFlow": "0.00", "CurrentElectricityQuantity": "2090960.00", "IsConnected": "1", "HealthValue": "10", "DeviceName": "Plug2"}, "dev_8": {"uuid": "xx", "name": "HAE_METER_v3", "internalAddress": "8", "type": "HAE_METER_v3", "supportsCrc": "0", "ccList": "42", "supportedCC": "42", "nodeFlags": [], "IsConnected": "1", "DeviceName": "HAE_METER_v3", "HealthValue": "10"}, "dev_8.1": {"uuid": "xx", "name": "HAE_METER_v3_1", "internalAddress": "8.1", "type": "gas", "supportsCrc": "0", "nodeFlags": [], "CurrentGasFlow": "860.00", "CurrentGasQuantity": "6739039.00", "DeviceName": "HAE_METER_v3_1"}, "dev_8.2": {"uuid": "xx", "name": "HAE_METER_v3_2", "internalAddress": "8.2", "type": "elec", "supportsCrc": "0", "nodeFlags": [], "CurrentElectricityFlow": "NaN", "CurrentElectricityQuantity": "NaN", "DeviceName": "HAE_METER_v3_2"}, "dev_8.3": {"uuid": "xx", "name": "HAE_METER_v3_3", "internalAddress": "8.3", "type": "elec_solar", "supportsCrc": "0", "nodeFlags": [], "CurrentElectricityFlow": "NaN", "CurrentElectricityQuantity": "NaN", "DeviceName": "HAE_METER_v3_3"}, "dev_8.4": {"uuid": "xx", "name": "HAE_METER_v3_4", "internalAddress": "8.4", "type": "elec_delivered_nt", "supportsCrc": "0", "nodeFlags": [], "CurrentElectricityFlow": "415.00", "CurrentElectricityQuantity": "10496674.00", "DeviceName": "HAE_METER_v3_4"}, "dev_8.5": {"uuid": "xx", "name": "HAE_METER_v3_5", "internalAddress": "8.5", "type": "elec_received_nt", "supportsCrc": "0", "nodeFlags": [], "CurrentElectricityFlow": "0.00", "CurrentElectricityQuantity": "42256.00", "DeviceName": "HAE_METER_v3_5"}, "dev_8.6": {"uuid": "xx", "name": "HAE_METER_v3_6", "internalAddress": "8.6", "type": "elec_delivered_lt", "supportsCrc": "0", "nodeFlags": [], "CurrentElectricityFlow": "0.00", "CurrentElectricityQuantity": "8009425.00", "DeviceName": "HAE_METER_v3_6"}, "dev_8.7": {"uuid": "xx", "name": "HAE_METER_v3_7", "internalAddress": "8.7", "type": "elec_received_lt", "supportsCrc": "0", "nodeFlags": [], "CurrentElectricityFlow": "0.00", "CurrentElectricityQuantity": "15886.00", "DeviceName": "HAE_METER_v3_7"}, "dev_8.8": {"uuid": "xx", "name": "HAE_METER_v3_8", "internalAddress": "8.8", "type": "heat", "supportsCrc": "0", "nodeFlags": [], "CurrentHeatQuantity": "NaN", "DeviceName": "HAE_METER_v3_8"}, "dev_10": {"uuid": "xx", "name": "FGSD002", "internalAddress": "10", "type": "FGSD002", "supportsCrc": "1", "ccList": "5e 20 86 72 5a 59 85 73 84 80 71 56 70 31 8e 22 9c 98 7a", "supportedCC": "5e 20 86 72 5a 59 85 73 84 80 71 56 70 31 8e 22 9c 98 7a", "nodeFlags": [], "IsConnected": "1", "DeviceName": "FGSD002", "AlarmStatus": "clear", "CurrentTemperature": "20.60", "CurrentBatteryLevel": "100", "TamperingDetected": "0", "CurrentState": "0"}}
Did some small checks today on a Fibaro plug and the switch can be turned on/off via:
Off http://192.168.x.x:10080/hdrv_zwave?action=basicCommand&nodeID=X&state=0 On Off http://192.168.x.x:10080/hdrv_zwave?action=basicCommand&nodeID=x&state=1
nodeID = internalAddress
But while switching in this way the "TargetStatus" which represent the on/off state of the device itself doesn't change while using the command from above. Switching via Toon will the "TargetStatus" change with 1 = On / 0 = Off.
Hopefully this information will be helpfull :)
Thanks for checking this, I hadn't noticed that the TargetStatus from the json output actually doesn't get updated with running those On/Off commands. I actually use this one from command line which comes down to the same:
curl --data "action=basicCommand&nodeID=X&state=1" http://192.168.xx.xx/hdrv_zwave?
When you check the plug at this page http://192.168.xx.xx/hdrv_zwave/
you see next to the on and off button another button named Update. With clicking that button the TargetStatus field from the json output actually does get changed to the correct status of the plug.
So I think in order to make those action commands work properly, we would have to send another command that mimics the update button on that toon page. However, -I don't know how to do that yet-.
Update; When I send this to the plug, it also updates the json output:
curl --data "action=GetBasic&nodeID=X" http://192.168.xx.xx/hdrv_zwave?
So that probably corresponds to: http://192.168.xx.xx/hdrv_zwave?action=GetBasic&nodeID=X
Hope this helps, cause it is the last piece needed to be able to use these plugs in Home Assistant in a way that you can turn it on/off, but also reliable read the current status of the plug, next to the power it measures.
Hi @cyberjunky , @Imperial-Guard , I was wondering if there is any energy among you to pick up this one where we left. Especially with the new Energy page in the latest Home Assistant versions where also individual devices that report electricity consumption can be added. It would make this integration amazing with the possibility of adding power reporting Fibaro plugs. Please let me know where I can help.
@cyberjunky Hi Ron, any chance that we can pick this up and integrate into this component? Currently I'm using one Fibaro sensor as measuring device.
The challenge is that the "dev_x" are dynamic for each setup, so we've have to search on FGWP011 / NAS_WR01Z and create and/or more sensors.
Bit ignoring that I've to download your latest version and make modifications to my own version :P
I will have a look, looked at it before, it requires a different config entry type, maybe just have a config entry type 'plug' for you can define a name and dev_x
Thanks for this. Currently I've the following added the following things. But for several plugs it should something be more dynamic. But at least below is a start :) Only not user friendly for the people without any python knowledge.
- SENSOR_LIST
"elecusageflowfib", "elecusagecntfib",
-
SENSOR_TYPES
SensorEntityDescription( key="elecusageflowfib", name="Fibaro Plug Power", icon="mdi:flash", native_unit_of_measurement=POWER_WATT, device_class=DEVICE_CLASS_POWER, state_class=STATE_CLASS_MEASUREMENT, ), SensorEntityDescription( key="elecusagecntfib", name="Fibaro Power Use Cnt", icon="mdi:flash", native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, device_class=DEVICE_CLASS_ENERGY, state_class=STATE_CLASS_TOTAL_INCREASING, ),
-
aysnc def
elif self._type == "elecusageflowfib": if "dev_8" in energy: self._state = self._validateOutput( float(energy["dev_8"]["CurrentElectricityFlow"]) )
elif self._type == "elecusagecntfib": if "dev_8" in energy: self._state = self._validateOutput( float(energy["dev_8"]["CurrentElectricityQuantity"]) / 1000 )