This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.
The Homey Community has been moved to https://community.athom.com.
This forum is now read-only for archive purposes.
The Homey Community has been moved to https://community.athom.com.
This forum is now read-only for archive purposes.
Homey and Fibaro HC2: Use a HC2 Global Variable change as trigger for Homey ... anyone?
mvdkallen
Member
Hi guys,
I can't manage to get this working and am stuck.
I'd like Homey to respond (.. execute a flow) based on a Global Variable change which is done by- and on my Home Center 2 controller. So Homey needs to read out the Global Variable on HC2 and once this Global Variable changes then Homey must respond instantly as well.
For some reason I can't manage to get this working... Can anyone check and support, please?
Instead of ditching one controller, I'd like both controllers to work together in my environment because I really see added value for a controller that can speak- and act on speech input.
Thanks and best regards,
Mark
I can't manage to get this working and am stuck.
I'd like Homey to respond (.. execute a flow) based on a Global Variable change which is done by- and on my Home Center 2 controller. So Homey needs to read out the Global Variable on HC2 and once this Global Variable changes then Homey must respond instantly as well.
For some reason I can't manage to get this working... Can anyone check and support, please?
Instead of ditching one controller, I'd like both controllers to work together in my environment because I really see added value for a controller that can speak- and act on speech input.
Thanks and best regards,
Mark
Comments
Thanks
And of course have HC trigger flows
Ok, one example is that I'd like Homey to say something when I set the alarm for certain room through the HC2.
For this example Homey must check the Global Variable called "alarmstatus" on HC2 and when it is set to "ingeschakeld" then it needs to say something.
(By the way, yes I installed the HTTP request flow cards app... I think it is just me who need to understand the trick here )
Thanks
damn lost my guide in this, hang on
local homeyhttp = net.HTTPClient()
You can't use spaces (dont know why) so i use "-" insted, and "----" x4 make a pause
-----
I use this in some of code: to remove spaces
spaceout = string.gsub(variable," ","-")
And btw dont see why you would let Homey tjek an Global variable on the HC, when HC do that just fine ,) but you can have Homey set a Global variable on the HC, i use that ;P
http://www.w3schools.com/tags/ref_urlencode.asp
Well kinda, not here:
weather2 = string.gsub((weather1)," ","%20")
Thanks for your advice.
In my situation I don't want Homey to change a Global Variable on HC2 (.. Homey always just have to respond on what happens by the HC2), or, (.. other example) Homey just have to say what Global Value is set on HC2 when I ask Homey to.
I ask: Hey Homey, what is the status of the alarm for room xyz?
Homey should respond: The alarm for room xyz is "set" (.. and "set" is actually the value of the Global Variable inside HC2).
So besides on what I listed above about Homey responding when the Global Variable on HC2 changes, I also would like to be able to ask Homey what the status is of the alarm. For this flow I need to let Homey read out the HC2 Global Variable value of "alarmstatus". How do I do that?
Sorry for the many questions, I'm going through a learning curve here
I see what you like to do, i have some guys looking into how to spilt a json array, like you do in HC, because that i think is what you can get from HC when you ask for the Global variables ...
But for now i made a "work a round" by calling a scene in HC for the alarm status
http://admin:yourpasswordhomecenterip:80/api/sceneControl?id=7&action=start
7 = id of your scene
But i do hope to figure out how to make Homey use a json array, just managed to do so in HC
Although this will work, I'm not fond of putting the login details into any URL.
I'd like to thank you for the above given support, I gave it a try and it is working. Though it is not fully what I am looking for; this way of working opens up some more ideas
Kind regards,
Mark
Hi,
You mentioned in an earlier post that you managed to let Homey change a global variable on Home Center 2.
Can you show me how you manage to do this, because no matter what I try with a flow on Homey, the HC2 keeps the global variable set on the same value as it was).
I must be overlooking something little here...
Thanks and best regards,
Mark
The goal is to send a http url to let homey say something. This I want to use when a status is changed on my Fibaro HC2.
I installed, in my new Homey, the HTTP request app. Made a flow from the screenshot example steenjensen posted.
When I post the url /api/app/com.internet/homeysay/welcome-home in my Firefox browser, I get an error:
{
- "status": 401,
- "result": "no_auth_method_found"
}I figured out how to get my token but where do I have to put this?
Help me out guys, I'm just don't get it... (as usual)
i use HTTP Put JSON
http://admin:xxxxxxx@xx.xx.xx.xx/api/globalVariables/Hometime
{"value":"MovieResumed"}
Hometime are the global variable in HC
and value are of course the value
Ah, that's the trick... I didn't include the {"value" part but added just the value name instead in the input window
Thanks a lot!
Br. Mark
Also by using "HTTP Get" you can start a scene
http://admin:xxxxxx@xx.xx.xx.xx:80/api/sceneControl?id=7&action=start
Clear! That works, thanks! Forgot to disable/enable the app to get it working.... For security reasons, can the token be used in a 'stand-alone' URL some way?
This code is for a scene you have to include in the Fibaro HC2.
1 - Make two global variables on the HC Variables panel named SC_Homey_Command and SC_Homey_Value
2 - Add a new scene with the lua code:
To test it you can make a VD with a button with the code below. Press the button to make your Homey speak.You need the setup example from steenjensen in his posting (seventh from the top).
I tried it and it is working. To activate homey to speak, just store a text in the SC_Homey_Value and the Homey variable in SC_Homey_Command. The scene shows debug messages for clarity.
BTW, you can use every HTTP Request Flow Cards GET Request trigger and store every value you want from your HC2 to your Homey! Just store the value in the HC2 global variable SC_Homey_Value and the GET Request trigger variable name in SC_Homey_Command.
Have fun!
After looking on the internet, I did found your post about 'homey talk' via Fibaro.
I did insert the code above, but couldn't get it work.
When I use the debug functionality, I receive following error:
[DEBUG] 13:00:24: line 25: invalid capture index %2
I don't understand what I am doing wrong (I am not a program expert)
This is what I included:
--[[
%% properties
%% events
%% globals
--]]
local globVarCommand = 'SC_Homey_Command'; -- Name of global variable to read command
local globVarValue = 'SC_Homey_Value'; -- Name of global variable to read command value
local homeyToken = ''; -- Not used yet
local homeyIp = '192.168.100.130'; -- IP-address of your Athom Homey
local function errorlog(str) fibaro:debug('<font color="red">'..str..'</font>');
end
end
local command = string.gsub(command,'%20','%%20');
local value = fibaro:getGlobalValue(globVarValue);
local value = string.gsub((value), '%20', '%%20');
local value = string.gsub((value),'3F','%%3F');
if debug then log(apiURL) end;
success = function(status)local result = json.decode(status.data);
if result.status == 200 then if debug then log('<font color="green">OK</font>') end ;
else
errorlog('failed');
if debug then log(status.data) end;
end
end,
error = function(error)
errorlog("ERROR");
if debug then log(error) end;
end
})
fibaro:setGlobal(globVarValue, '');
Hope you or anyone on this forum could help.
You have to add this in the Variables Panel.
and is changed the %s to '%20'
Also, can you add the global variable trigger:
BTW, this is code only for using in a scene, not a Virtual Device....
Seems like I could fix the scene. When I now start the scene I get following error message:
[DEBUG] 11:36:33: http://192.168.100.130/api/app/com.internet/homeysay/blaaaah-blah----a a blaaaaah---- a a blaaaaaaaa---bla
[DEBUG] 11:36:34: failed
[DEBUG] 11:36:34: {"status":401,"result":"no_auth_method_found"}
Based on mu understanding, it looks like I need to insert somewhere my Homey Credentials. Any idea how I could resolve ?