Integrate with SQL

Hi. I am very new. Like, today new.

I made my own home automation, with blackjack and ... SQL. It works well, but I bought a Hubitat because I wanted wireless wall switches, and it seemed easier than to manually implement z-wave.

Basically, everything is written into this table, and some daemons make sure whatever is there gets executed or kept up to date.

Here's my question. Let's say I have a Sonoff TRVZB (heater valve, zigbee). I rotate the set temperature and Hubitat updates. Cool. How do I get that temperature into my SQL? I remember reading you can just use websockets to, say, call for http://server/SetValue.php?id=7&value=3 but now that I played with the device it seems it only likes to do rules with its own defined devices.

Do I need to write a driver? Is there one that already exists, and I am simple? Did anyone try to use SQL before? How do I give sensor data TO Hubitat? Is there a generic driver I can use of do I have to write one?

Have you seen Maker API? It's HTTP REST, not websockets (there's an unofficial interface for that too but it only gets events out, not commands in). But it sounds like it's the kins of thing you want.

3 Likes

@Ndi

Welcome to the Hubitat community! As indicated by @bertabcd1234, Maker API is broadly useful to integrate Hubitat with external systems for any purpose. Common purposes include: automation and recording data.

You should be able to use Maker API to control Hubitat devices via SQL. You can also create virtual sensors in Hubitat, and populate their state using input from SQL.

I don't use SQL, but I use Maker API to integrate Hubitat with Node-RED and Homebridge - works very well for this purpose.

Thank you for the pointer, I will look into it and (probably) be back.

If it's bi-directional, I'm probably set. I am an experienced developer and the other side of Hubitat is an in-house solution I can easily adapt to any TCP/IP protocol.

It is bi-directional. Uses HTTP POST.

There are multiple approaches possible here. You can receive updates from Hubitat using HTTP. Or receive them via an undocumented (but stable) websocket interface. Updates to Hubitat can only be sent via HTTP.

http://192.168.X.X/apps/api/14/devices/2/attribute/thermostatSetpoint?access_token=Y

{"id":"2","attribute":"thermostatSetpoint","value":22.0}

http://192.168.X.X/apps/api/14/devices/2/setHeatingSetpoint/24?access_token=Y

{"id":"2","attribute":"thermostatSetpoint","value":24.0}

That was ... surprisingly painless. Thank you all, I'm good from here.

2 Likes