Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HomeAssistant Rest API test Driver
#1
Looks like Home Assistant Rest API works pretty good with CQC and should help those of use that need to add a few unsupported devices to CQC.

As everyone knows there is no other HA system out that compares to the configurability of the GUI interface you get from CQC. So why not just let HomeAssistant poll the device and CQC can lookup state/attributes from HA.

Here is a first cut of a test driver.
Driver install prompts:
1. HomeAssistant Long-lived access token (see below)
2. Polling Interval (default is 5 seconds)
3. HomeAssistant Hub IP address example: 192.168.1.1
4. List of HomeAssistant Entities to be polled (see format below)


.zip   HomeAssistant_0.2.zip (Size: 31.44 KB / Downloads: 3)

Note:
  • It polls the local HomeAssistant Hub.
  • It does one small "state" poll for each device at poll time. (so keep it to a small number of devices not supported by CQC)
  • Driver creates fields based on HomeAssistant entity names that are specified to poll  at driver configuration.
  • HA can report locks in strange states(jammed,unkown,etc) in this case the lock will be set to false(unlocked) just like the HA app does.
  • CQC has a 8 second HTTPost timer and HA seems to have a very rare 40 second timeout(when unplugging z-wave devices, HA seems to pend all post requests for up to 40 seconds until HA sets that status again). I have only seen it on sending commands to locks. guess HA pends on the lock to finish unlocking/locking,etc. In this case driver will increment the $LostConn field in the driver status screen. 
After a few weeks of testing. Seems to work well at 5 seconds poll times.

You need to Generate a Long-lived access token(Personal Access Token)
Home assistant -> "your profile" -> Long-lived access tokens
https://community.home-assistant.io/t/ho...cess-token


Devices to Poll:
Format is  Entity ID  in HomeAssistant (example below)
Home assistant -> Settings -> Devices & services -> Entities

example:
light.scene_capable_plug_in_dimmer,light.sengled_solar_light,switch.ktest_appliance_switch,lock.front_door_lock,sensor.workshop_flood_sensor_air_temperature,binary_sensor.workshop_flood_sensor_water_leak_detected


Please feel free to fix, enhance or change driver as needed.
    maybe:
  • enhance Lights to do color light fields
  • Add more device types as I only added light, lock, switch, and sensors.(or a more elegant lookup table of some kind)
  • Sensor should work for any sensors and binary_sensors as they are just text fields.

Obviously the Rest API Driver is not intended for a bunch of devices/entities/sensors. The "http://{{hass_url}}/api/states/{entity ID}" poll  is pretty small and efficient. unlike the smartthings hub where you hand to pull a ton of capabilities and parse out.

One major change from smartthings api is all commands to HomeAssistant are done by calling a Service "http://{{hass_url}}/api/services/light/" instead of just calling the device(smartthings) or EntityID(HomeAssistant) and setting the attributes.


I see no reason someone couldn't write a cool websockets driver so we can migrate all our CQC devices to HomeAssistant and still use CQC as the GUI frontend.

https://developers.home-assistant.io/docs/api/websocket
Denon 3808ci, 2112ci ,Sonos, NoVo Grand Concerto, Z-Wave(Lights,Locks), Zigbee switches,
iPads,Tivo,Hikvision,Elk-M1,Somfy RTS blinds+ZRTSI, Amazon Echos+Dots, Polk XRT12,
Honeywell Wi-Fi 9000, Rainmachine, Home Assistant, Tesla model S,
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)