Running custom apps on the Flic Hub
-
@oskar Wow 8 months already since this was said.
How about giving us developer access if we acknowledge that we understand the risks in the app? The SDK was promised in the indiegogo campaign so seems like it should be delivered.
I would be fine with something like "Allow ssh access to my hub" with a warning about the risks of doing this. Since it's linux we can pretty much take if from there as developers. Of course the ssh will have to allow sudo for this to be all that is needed.
-
Hi!
what is the progress made on the topic? I would be highly interested to run a custom app on the flic hub. Moreover it would be very helpful to have an API available on the hub to enable configuration of the hub without a mobile. Any comments on this?
-
BTW - running node red on the flic hub seems like a perfect solution...
-
It seems that you are after exactly what I want. Initially I came here looking for a way of quickly configuring a large number of flic buttons on the hub via my desktop. But your other solution of configuring the hub with one url that then passes button name and action (either through url params or with a push request and a bit of json) would be great.
At the moment I have 3 raspberry Pi 3 dotted around the house. They all run the linux flic daemon and have node red running to actually do the action. There is a flic node-red node that make configuring this stuff really easy.
Lately however I have been having to reboot my pi frequently as for some reasons the flic button daemon stops working (it has been fine for about a year).
My proposal is to have hub that connects to all the buttons that will hopefully be more stable. Each button will then just call a url on node red that will then handle the request.
One of my use cases is that I want a flic button to toggle all the lights and wemo devices in a living room based on the state of one of the lights. You can toggle in the flic app but not toggle a wemo based on the current state of a hue light for example. This is very easy in node-red.
-
I know this is slightly tangential to the original post, but I would like to access greater functionality, not so much by running things on the hub, but via the flicd-bridge, which I presume is running on the linux host in the hub. I use Openhab, and the Openhab binding for flic can talk to a remote linux host via the bridge. However, the bridge needs to be configured to allow it to talk outside the local host, which again I presume is locked down to the hub.
Having this able to be configured via the mobile app, or an ssh session would be great.
-
@sawtaytoes said in Running custom apps on the Flic Hub:
I think you're onto something @stuart. I could see where that'd be useful. You'd still have to have a centralized server for your configuration settings, but you'd manage that yourself and the Flic hub is literally just that, a dumb hub. No matter what happens to any button, it sends an HTTP request in a specific format to a certain address. That gives you all the power you need, and you can control everything from a Raspberry Pi or even an ESP8266.
In this way (provided I understood you), you lose the Flic app connections to 3rd party manufacturers and have to roll your own solutions.Yes, that is exactly what I am proposing.The solution I have set up consists of a hub with 8 buttons, each configured with a URL which calls the micro-service using the URL noted before. Then te hub is essentially dumb and I can run what I want. It would be ideal to run this simple web service as a docker within the hub as that provides the security that Flic want whilst giving me the flexibility to do what I want.
For now I am running the prototype on a VM but will probably move to a container if I start to use it for anything important.
I have my own solutions too, but I'd prefer to do everything through the official app (provided I'm understanding you). I'm sure that's the intention on Flic's end as well. My friends and family wouldn't be able to use a Flic hub and do the same things as me if they have to flash a Raspberry Pi with my own custom software that they now have to maintain.
Yes, but once you have set up the micro-service to run some scripts, there is no reason that this would need maintaining if the requirement doesnt change (depending on your coding skill level). Users could easily share their own scripts and recipes as well.
A significant benefit of this is that it will still work even if you have no internet connection.
I can share the micro-service on Github if you like. It is rudimentary but works and is easily extensible.
Because of the current limitation of mobile-only configuration; why not allow uploading a JSON config file? I can generate these in any programming language and maintain them on GitHub instead of having to put them all individually in the Flic Hub; otherwise, this is going to be completely unusable.
This would work in some situations but I would want to create my own arbitrary script files to do whatever and JSON would be too restrictive. But for my prototype web-service, it would be easy to implement such a facility.
I've written about the scaling issue here:
https://medium.com/flicblog/controlling-iot-devices-with-the-flic-of-a-button-1349c81bddefI think for this first iteration, scaling the number of buttons is something power users are going to be doing. In the future, that shouldn't be the case, but for now, it's something only affecting folks like me with whole house solutions and 40+ buttons. That's the intention right? Or am I using them in a strange way?
The web-service prototype would also enable as many hubs as you want so you have effectively infinite buttons. See the proposed URL - specifies hub as well as button and action.
(This could just as easily be a JSON string instead of a GET)I'd like a way to actually use the hub, but I don't know if I'll be able to with its current software as I've detailed here:
https://community.flic.io/topic/17298/feature-request-flic-hub-and-app-enhancements-for-scaleResponding so some of your points, to test the web-service, I have presented a simple web page so I am able to execute the same action as if I had pressed the button. Of course, you could call the URL from one of the many Android apps that just send web requests. I had thought about how access is restricted so it would be easy to add API tokens or authentication to ensure only the right people can do the things.
I agree that some more Flic config (debouncem triple click etc) would be useful; to enable better tuning in.
-
I think you're onto something @stuart. I could see where that'd be useful. You'd still have to have a centralized server for your configuration settings, but you'd manage that yourself and the Flic hub is literally just that, a dumb hub. No matter what happens to any button, it sends an HTTP request in a specific format to a certain address. That gives you all the power you need, and you can control everything from a Raspberry Pi or even an ESP8266.
In this way (provided I understood you), you lose the Flic app connections to 3rd party manufacturers and have to roll your own solutions. I have my own solutions too, but I'd prefer to do everything through the official app (provided I'm understanding you). I'm sure that's the intention on Flic's end as well. My friends and family wouldn't be able to use a Flic hub and do the same things as me if they have to flash a Raspberry Pi with my own custom software that they now have to maintain.
Because of the current limitation of mobile-only configuration; why not allow uploading a JSON config file? I can generate these in any programming language and maintain them on GitHub instead of having to put them all individually in the Flic Hub; otherwise, this is going to be completely unusable.
I've written about the scaling issue here:
https://medium.com/flicblog/controlling-iot-devices-with-the-flic-of-a-button-1349c81bddefI think for this first iteration, scaling the number of buttons is something power users are going to be doing. In the future, that shouldn't be the case, but for now, it's something only affecting folks like me with whole house solutions and 40+ buttons. That's the intention right? Or am I using them in a strange way?
I'd like a way to actually use the hub, but I don't know if I'll be able to with its current software as I've detailed here:
https://community.flic.io/topic/17298/feature-request-flic-hub-and-app-enhancements-for-scale -
To be able to create a programmatic response to flic actions from the hub, I have created a quick http listener that takes a query string and lets me run whatever scripts I want on another computer.
This takes a get request as follows:
http://flic-hub-listener/actions?hubname=one&flicname=one&action=click
The issue is that I have 4 flics on one hub, each with 3 actions therefore I need to paste a modified action in 12 times to make this work.
As mentioned in my earlier post(https://community.flic.io/post/18066) it would be much easier if I can create actions for all buttons on the hub, for example a URL with variables for hub name, flic name and action like this:
http://flic-hub-listener/actions?hubname={hub_name}&flicname={button_name}&action={button_action}
This will be much more robust and easier to manage for those of us who want to build their own scripts with the hub instead of using the supplied apps. These variables may be a benefit to other apps as well.
-
@oskar A further thought would be to set up an action for all buttons on a hub which calls a URL with variables to indicate which button and trigger. For example, this would enable me to construct a URL like this on the hub itself (not per button):
https://my-listener/{button_name}/{button_action}
This would simplify management and just require a button adding without having to fiddle with the settings for each one.
As a developer, this would make it easier and more reliable to run arbitrary scripts elsewhere.Otherwise I may be better off just using an RPi 3 as described here: https://community.flic.io/topic/10/flic-for-pi3
-
Thanks @oskar
There are a few ways to achieve this but there are some challenges that we need to get past first. Right now the hub is only configurable using mobile apps, which can be quite limited if you want to write custom scripts.
Config via mobile - A web interface on the hub would be an advantage. You could use a variation of https://github.com/openwrt/luci/wiki which is a lightweight, fast and robust interface. It has the advantage that you can add functionality as you go without having to think of everything at the start which works well for a developing product.
There is also the security aspect of letting hardware on a local network execute arbitrary code.
We are currently trying to figure out a way to make this available in an easy-to-use way while maintaining a secure platform.Security is an issue and more prevalent in IoT as many users do not have the knowledge of the issues and generally end up with convenience which is almost always at the cost of security. (I posted a separate topic about security yesterday)
Thinking about the Flic Hub security, you could run arbitrary code in a docker which prevents any of the code affecting the base hub. It also creates a situation that the docker image can be exported and shared with others, creating lower-level apps with more power. As a point of reference, AsteroidOS have containers on smart watches (https://asteroidos.org/).
Regarding network security, either a user manages this by deploying another device on their network which if anything creates further risk, or the user posts to an external server which has it's own implications. So from a user perspective, having one device to run the code is likely to be less risky than the other options.
SJM
-
Hi!
Yes, the hub is Linux based so technically there is potential to add user defined functionality to the hub.
There are a few ways to achieve this but there are some challenges that we need to get past first. Right now the hub is only configurable using mobile apps, which can be quite limited if you want to write custom scripts. There is also the security aspect of letting hardware on a local network execute arbitrary code.
We are currently trying to figure out a way to make this available in an easy-to-use way while maintaining a secure platform.
As of now, the only way to make custom integrations is to run a web server on your local network and use HTTP Request to trigger an event on your server.
If you have any suggestions on how you would like this feature to look, please let us know!
-
I agree. I understand that the hub is Linux based so would be good to be able to trigger local shell scripts, then anything is possible.
-
Also interested on platform capablities of hub, like some add-ons/packages/custom apps