cyberjunky / home-assistant-custom-components

My custom components for Home Assistant
MIT License
71 stars 19 forks source link

Get status of Zwave smart plug #15

Closed Jeltel closed 5 years ago

Jeltel commented 5 years ago

I see how you get the data from the smartmeter and boiler. But how to get the data of the smartplugs? The smartplugs show up in the zwave devices: http://192.168.1.11:10080/hdrv_zwave?action=getDevices.json

"dev_5": {"uuid": "9426f408-6736-4e19-a6c4-266f71a5696c", "name": "Lampjes", "internalAddress": "5", "type": "NAS_WR01Z", "supportsCrc": "0", "ccList": "5e 72 86 85 59 5a 73 70 25 27 71 32 20", "supportedCC": "5e 72 86 85 59 5a 73 70 25 27 71 32 20", "nodeFlags": [], "IsConnected": "1", "DeviceName": "Lampjes", "TargetStatus": "0", "CurrentElectricityFlow": "0.00", "CurrentElectricityQuantity": "9200.00", "HealthValue": "10"}, Where nothing changes when switching the devices on or off. Sothe CurrentElectricityFlow stays at 0.00 and the CurrentElectricityQuantity stays at 9200. I thought these would change, as some other wich would represent the current status of the smartplug. IsConnected does change when the smartplug is removed from a wall socket.

And I can switch the smartplugs with: http://192.168.1.11:10080/hdrv_zwave?action=basicCommand&nodeID=4&state=1

But how to get the status and the elec_flow of the smartplugs? I can't seem to find it on the devices and googling doesn't help.

cyberjunky commented 5 years ago

I do not know where this information is kept, and if it's available via local JSON.

Jeltel commented 5 years ago

I've found out, but forgot to post the result here.

http://toon-ip:10080/hdrv_zwave?action=GetBasic&waitForReponse=1&timeout=120&nodeID=6

Is where the status is kept. You'll get a json back:

{
"value":"0x00",
"nodeId":"6"
,"result":"ok"
}

Where 0x00 stands for of, and 0xFF stands for on.

Full Switch code:

switch:
  platform: command_line
  switches:
    neo_coolcam_lampjes:
      command_on: '/usr/bin/curl "http://toon-ip:10080/hdrv_zwave?action=basicCommand&nodeID=5&state=1"'
      command_off: '/usr/bin/curl "http://toon-ip:10080/hdrv_zwave?action=basicCommand&nodeID=5&state=0"'
      command_state: '/usr/bin/curl "http://toon-ip:10080/hdrv_zwave?action=GetBasic&nodeID=5"'
      value_template: '{{ value_json.value == "0xFF" }}'

Where nodeID is the id of the plug.