@rob-loosx many thanks for these examples, really helpful. I wonder if you can help with an integration I need for LightwaveRF which uses UDP. The API for it is here and I'm wondering if your UDP script would be a starting point for this? Unfortunately my programming is limited so I doubt I can work out what needs changed but if you or anyone can point me in the right direction that would be great.
Latest posts made by andy
-
RE: Some Hub SDK examples
-
RE: HTTP Request for LightwaveRF Link
@Emil many thanks for that. Yes looks like it's entirely possible using the SDK. However I'm a complete novice when it comes to coding and this is probably beyond my capabilities.
If anyone else has written a script which will integrate LightwaveRF Link into Flic that would be great.
-
HTTP Request for LightwaveRF Link
I'm trying to configure a Flic HTTP Request via the Hub LR to switch on/off a LightwaveRF socket. The API for LightwaveRF is here:
LightwaveRF APII've been trying to get the correct syntax for this in the HTTP Request on the Hub but have failed so far.
Anyone got this working and can advise on the correct format for this to work?
-
RE: Flic2 Hub & http Request
OK as Flic support failed to respond to my emails and haven't been much help generally I ended up turning to Global Cache support and they solved the issue for me. I thought it might be helpful to someone else if I posted the solution. This may also work for other http requests using JSON.
So if you have the IR code for a device and function then this can easily be added as an http request within the Flic app. First you need the code to be in JSON format. The best way to do this is with iLearn which is available for Windows and Mac. The Mac version isn't an official application from Global Cache but a third party. However it works well as I am a Mac only user.
In my case the JSON code for the IR commands was:
{"frequency":38095,"irCode":"342,171,22,21,21,22,21,21,22,21,22,21,21,21,22,21,22,21,21,21,22,21,22,21,22,21,21,64,21,21,22,21,22,21,21,21,22,63,22,63,22,21,22,63,22,21,21,21,22,21,22,63,22,21,22,21,21,64,21,21,22,63,22,63,22,63,22,1829,342,85,21,3661,342,85,22,3660,342,85,22,3660,342,85,22,3809","preamble":"","repeat":1}
So once you have this then go into the Flic app, select which button function you want to assign and select HTTP REQUEST. In the URL field, enter the IP address of your unit followed by the send IR api:
http://[ip address of your unit]/api/v1/irports/[port number]/sendir
You need to make sure you enter the correct ir port number. If you have the tri IR lead connected to a Global Cache Flex then the port numbers are 1,2 & 3. The IR emitters should also be labelled. So if the device you're looking to control has emitter 1 connected to it, then enter:
http://[ip address of your unit]/api/v1/irports/1/sendir
Then ensure you select POST as the method for sending the packet.
In Content Type enter:
application/json
Under Body paste in the IR code in JSON format. It must be enclosed within {}. iLearn will do this automatically for you so it's just a matter of copying and pasting.
Click Done to ensure the entry is saved and it should now work.I hope this helps someone else and I hope that Flic Support takes note of their poor levels of response and technical support. I'm a Kickstarter backer and think the new hub and buttons are excellent. I couldn't be happier with the hardware but please improve your technical support or at the very least have more documentation for http requests through Flic. For me it's pretty much all I'm using the hub for as most of my devices aren't natively listed and I therefore need to send http api commands for what I want to control.
-
RE: New Flic Hub - not able to connect to my sonos
@beat-roos I had the same problem. I had to force close the app and restart several times before it finally found the SONOS players.
Keep trying and it should eventually find them. -
RE: Flic2 Hub & http Request
@Emil Have spent several hours trying with curl but no success. The code works as I’m able to send it through the test facility from Global Cache. However I can’t get the formatting correct for the http api request.
-
RE: Flic2 Hub & http Request
@Emil Thanks for the reply. I’ve used an application called POST but I haven’t been able to get it to work which is why I was hoping for some guidance on the formatting.
If anyone can help with the correct format to enter this it would be appreciated. -
RE: Flic2 Hub & http Request
OK having successfully got one http request working I now need to integrate an IR command sent to a Global Cache Flex IP2IR unit. I’ve successfully captured the correct IR code and having tested this code, it works. However I cannot work out the format within the Flic Internet Request to successfully send the command. Global Cache have a very useful API document which shows the format the http request needs sent. It must be a POST request and the format is as follows:
IR COMMAND TRANSMISSION
When sending IR commands to a Flex unit via HTTP, an HTTP POST is used to send the JSON packet as shown below.
HTTP/1.1 POST
<Base URL>/irports/<IR port number>/sendir
Header Values:
"crossDomain" must be true if issuing this command from the web page of a different Flex unit
{
“frequency”:“<FrequencyString>”,
“preamble”:“<PreamblePulseTrain>”,
“irCode”:“<IRCodePulseTrain>”,
“repeat”:“<RepeatCount>”
}Where:
<FrequencyString> is the frequency of the command in hertz (Hz)
<PreamblePulseTrain> is a comma separated list of numeric values signifying the first portion of the IR command that is only fired once. This portion is not repeated when using a repeat count.
<IRCodePulseTrain> is a comma separated list of numeric values signifying the full IR command when not using a preamble. This portion of the code is repeated when using a repeat count.
<RepeatCount> is the number of times that the
<IRCodePulseTrain> is to be repeated after sending the preamble of the command in the case that it is used.Can anyone help with how to enter this within the Flic app under Internet Request? The IR code I need to send is:
sendir,1:1,1,40506,1,1,343,182,22,22,22,22,22,22,21,22,22,22,22,22,21,22,22,22,22,22,21,22,22,22,22,22,22,67,22,22,21,22,22,22,22,67,22,67,22,22,21,68,21,68,21,22,22,22,22,22,21,22,22,22,22,67,22,22,22,22,21,68,21,68,21,68,21,1945,342,90,22,3892,342,90,22,3893,342,90,21,3893,342,90,21,3893,342,90,22,3892,342,90,22,3893,342,90,21,3893,342,90,22,3892,342,90,22,3892,342,90,22,3893,342,90,21,3893,342,90,22,3892,342,90,22,3893,342,89,22,3893,342,90,21,3893,342,90,22,3892,342,90,22,3893,342,90,21,3893,342,90,21,3893,342,90,22,3892,342,90,22,3893,342,90,21,3893,342,90,22,3892,342,90,22,3892,342,90,22,3893,342,90,21,3893,342,90,22,3892,342,90,22,3893,342,89,22,3893,342,90,21,3893,342,90,22,3892,342,90,22,3893,342,90,21,3893,342,90,21,4050 sendir,1:1,1,40506,1,1,343,182,22,22,22,22,22,22,21,22,22,22,22,22,21,22,22,22,22,22,21,22,22,22,22,22,22,67,22,22,21,22,22,22,22,67,22,67,22,22,21,68,21,68,21,22,22,22,22,22,21,22,22,22,22,67,22,22,22,22,21,68,21,68,21,68,21,1945,342,90,22,3892,342,90,22,3893,342,90,21,3893,342,90,21,3893,342,90,22,3892,342,90,22,3893,342,90,21,3893,342,90,22,3892,342,90,22,3892,342,90,22,3893,342,90,21,3893,342,90,22,3892,342,90,22,3893,342,89,22,3893,342,90,21,3893,342,90,22,3892,342,90,22,3893,342,90,21,3893,342,90,21,3893,342,90,22,3892,342,90,22,3893,342,90,21,3893,342,90,22,3892,342,90,22,3892,342,90,22,3893,342,90,21,3893,342,90,22,3892,342,90,22,3893,342,89,22,3893,342,90,21,3893,342,90,22,3892,342,90,22,3893,342,90,21,3893,342,90,21,4050
-
RE: Flic2 Hub & http Request
@Emil OK after a lot of experimenting I managed to get it working. Think it was finger trouble on my part. It is Basic authentication and it’s now working well.
Thanks for the reply. -
RE: Flic2 Hub & http Request
@Emil I’m not 100% sure but think it’s actually Digest Authentication.
If I enter the following in a browser window the command works perfectly:
http://username:password@10.33.22.126:85/cgi-bin/split.cgi?action=enableTour&channel=1&enable=trueI’ve converted the actual username:password to base64 but the command is not being sent correctly by the hub.