Hello community,
Might there be an option to have something like a virtual switch that can be controlled from an external http call or similar?
The use case is:
I have Vera Hub that has a unique function/application that i can not currently replicate on Hubitat. When the vera application signals action is needed i need Vera to be able to turn on/off a virtual switch in Hubitat so the Hubitat hub can perform actions on lights etc
Yes, expose the virtual switch on Hubitat to MakerAPI. It is a simple HTTP GET API that permits external systems to control Hubitat devices. More information in the Hubitat documentation, linked to below:
Very nice, thanks!
I am missing something on getting a simple switch to turn on/off. Might you please be able to give an example of a http url to turn off the below switch (assuming Hub is 12.3.4.5 i.p address and api id =41)
{"name":"Aeotec Smart Switch 6","label":"Garage Switch","type":"Aeotec Smart Switch 6","id":"23","date":"2023-07-17T02:33:35+0000","model":null,"manufacturer":null,"room":"Garage","capabilities":["Configuration","Actuator","VoltageMeasurement","Refresh","PowerMeter","EnergyMeter","Outlet","SwitchLevel","Switch","Sensor"],"attributes":{"powerL":"0.000","dataType":"NUMBER","values":null,"energy":"0.000","level":"99","voltage":"239.435","current":"0.000","powerH":"0.000","currentL":"0.000","energyDuration":"0.11 Minutes","frequency":null,"power":"0.000","currentH":"0.000","switch":"on","voltageL":"239.435","voltageH":"239.435"},"commands":[{"command":"configure"},{"command":"off"},{"command":"on"},{"command":"refresh"},{"command":"resetCurrent"},{"command":"resetEnergy"},{"command":"resetPower"},{"command":"resetVoltage"},{"command":"setLevel"}]}]
I keep getting the following error in logs:
errorjava.lang.NullPointerException: Cannot invoke method getAt() on null object on line 465 (method sendDeviceCommandSecondary)
I used the following:
http://[i.p address]/apps/api/[api ID]/devices/[device ID]/off/?access_token=[access token]
Thanks
So you are getting close.... I'll provide you with an example....
From the Maker API App page, which I expect is where you have got the sample URL from, the secondary part is optional, i.e. if you need parameters, etc, which we don't for an on/off command.
I have recently setup some devices related to my lighting control in a Z2M instance and used Node RED to interact with my motion lighting setup to disable/enable the motion lighting when I use the devices in Z2M (Hue Tap Dials). Here is the Maker API call I make to turn off a virtual switch (with my IP Address and Access Token blanked out), notice the question mark comes immediately after the command name when there is no parameter:
I'll get an example of one with a parameter to show you the difference.
And here's an example (from a different Maker API instance) of a command with a parameter, setBattery on a virtual battery sensor, note the extra forward slash between the command and the parameter value of 65, before the question mark and access token.
Thank You, looks like i had one too many /.. Very cool and powerful app, i can now integrate my vera hub function with Hubitat through the use of virtual switchs. So far i am keeping vera for this one function where Rigpapa (vera developer) wrote and interface from Vera to Emby (similar to plex). My use is as follows:
- If media room Emby client = playing movie (can select by emby folders)
- If motion is detected on one of the external entrance cameras then:
- Bookmark current movie position
- Stop movie on media room emby client (virtual switch in Hubitat triggered by emby Luup http call
Vera Luup code for Movie stops, raise Lights to 40%
luup.inet.wget "http://[i.p address]/apps/api/[api id]/devices/[device id]/on?access_token=[access token]") - Play relevant camera feed on media room emby client
- When camera feed stops, resume movie from bookmark position (virtual switch in Hubitat trigger by Luup call from vera and Emby integration)
Problem to tackle now is that i am placing all zwave sensors into Hubitat and will need to use them as a trigger for the emby integration on Vera Hub. Might the be some way to send http command from Hubitat to vera where i can setup a virtual sensor and perform similar action but on the Vera hub?
Rule Machine would be my go to, but not sure if one of the simpler automation Apps on HE can also do this... Let me find a rule for you....
Here's an example rule I have when I transition to Evening mode, which synchronises that with Tasker on some of my Android devices using an HTTP Get action.
To setup an action like this in an RM rule, you need to select the following when creating an action, entering the HTTP URL you want to call:
Thanks again,
Does this RM example only send Get commands, I assume I would need a post command ?
I will give this a try and report back
I expect it will, I know it can send them from other apps.
The RM Get command works great with "theraldb" Virtual Device plugin for Vera
Edit startup code then use the below url's for control on/off from Hubitat RM HTTP Get call:
-- http://ip:3480/data_request?id=lr_updateSwitch&device=170&status=0
function lr_updateSwitch(lul_request, lul_parameters, lul_outputformat)
local devNum = tonumber(lul_parameters["device"], 10)
local status = tonumber(lul_parameters["status"] or "0")
luup.variable_set("urn:upnp-org:serviceId:SwitchPower1", "Status", status or "1", devNum)
end
luup.register_handler("lr_updateSwitch", "updateSwitch")
Virtual switch on
http://vera i.p:3480/data_request?id=lr_updateSwitch&device=device id&status=1
Virtual switch off
http://vera i.p:3480/data_request?id=lr_updateSwitch&device=device id&status=0
Thanks alot for your help, really appreciate your time!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.