Fully Kiosk Browser integration


(Sebastian) #1

I just started playing around with Fully Kiosk Browser (FKB) and as it has a nice REST API I was wondering if there is a binding available to nicely interact with OH2. Since there is none, I made use of HTTP binding in order GET and POST some values that made sense in my setup.

I’m using Fire HD 10 tablets wall mounted with HABpanel to interact with Openhab. When having FKBs PLUS license (well spent 6 Euros), you can use motion detection, REST API and some other good stuff that makes FKB a swiss army knife. I really like it and just started to play around.

Since I havent found much OH2 related FKB docu, I’d like to start an items/rules sharing thread so that other can participate in grabbing info as well as adding their use-cases and item definitions.

So to start here are my items:

 // Switch Display ON & OFF
 Switch eg_flur_tablet_display
   "Tablet Display"
   (gEgTablet)
   { http=">[ON:POST:http://192.168.23.140:2323/?cmd=screenOn&password=password] >[OFF:POST:http://192.168.23.140:2323/?cmd=screenOff&password=password]" }

 // GET Display status info from device and update switch above based on .rules file
 // As per: https://docs.openhab.org/addons/transformations/jsonpath/readme.html
 String eg_flur_tablet_display_json
   "Tablet Display JSON [%s]"
   (gEgTablet)
   { http="<[http://192.168.23.140:2323/?cmd=deviceInfo&password=password&type=json:30000:JSONPATH($.isScreenOn)]" }

 // Screenbrightness in % (set & get)
 Dimmer eg_flur_tablet_brightness
   "Tablet Helligkeit [%d %%]"
   (gEgTablet)
   { http=">[*:POST:http://192.168.23.140:2323/?cmd=setStringSetting&key=screenBrightness&value=%2$s&password=password] <[http://192.168.23.140:2323/?cmd=deviceInfo&password=password&type=json:30000:JSONPATH($.screenBrightness)]" }

 // Timer in seconds, when screen shoud go off again
 Dimmer eg_flur_tablet_ScreenOffTimer
   "Tablet Screen Off Timer [%d sec]"
   (gEgTablet)
   { http=">[*:POST:http://192.168.23.140:2323/?cmd=setStringSetting&key=timeToScreenOffV2&value=%2$s&password=password] <[http://192.168.23.140:2323/?cmd=listSettings&password=password&type=json:30000:JSONPATH($.timeToScreenOffV2)]" }

 // GET battery level from device
 Number eg_flur_tablet_bat
   "Tablet Battery [%s %%]"
   (gEgTablet,gBattery)
   { http="<[http://192.168.23.140:2323/?cmd=deviceInfo&password=password&type=json:30000:JSONPATH($.batteryLevel)]" }

In case you turn on the display via other means (motion detection, REST webpage, etc), it would be helpful if OH recognizes this and updates the Switch item accordingly. Thus you have to query the JSON and switch the item with the following rule:

 rule "eg_flur_tablet_display_json: convert JSON to Switch"
 when
   Item eg_flur_tablet_display_json changed
 then
   logInfo("eg_flur_tablet_display_json","Has value: " + eg_flur_tablet_display_json.state.toString)
   if(eg_flur_tablet_display_json.state.toString == "true"){
     eg_flur_tablet_display.postUpdate(ON)
   } else {
     eg_flur_tablet_display.postUpdate(OFF)
   }
 end

image

Having all this in a nice small binding using one thing item per tablet would be really handy. Since I’m not a real developer others might pick this up. I’ve seen similar intergrations for e.g. HASS.
Hope this helps.
Best Seb


(david) #2

Very nice. About to start with my fire device this week. It would be great to also post your settings for FKB. I get the impression one of the tricky things is to disable screen lock, so anything around that would be good too.


(Dominic Bonneau) #3

I did the exact same thing but with the exec binding and the command CURL … Your things look cleaner


(Sebastian) #4

Hey @david,
I havent changed much in FKB settings yet other than ordering the license and enabling “motion detection” as well as “remote admin”. I’m still about to tweak the motion settings since the device wakes up badly during night times. Once I have a working config, I’m happy to share.

@Dominic_Bonneau your curl items inspired me to start this thread. Thanks for that. I’m still checking if HTTP binding config can help tp optimize the config efforts. Then it might be even cleaner to setup. Will share the results later.

My main use-case is the abilty to control the tablet from OH via FKB. I have some rules so that the “Screen on time” is shorter at night times and I also reduce the brightness at night.
When walking through the dark corridor at night I dont want the tablet to scream at me in 100% brightness for 5mins. But during day times, the tablet should be turned on longer and brighter.


(Alexander) #5

I am also playing with a fire tablet (fire7) as wall mounted control unit with FKB.

In spite of the problem with the unlock-screen and the advertisement everything works fine so far. i just think, that loading times are bad with the FKB - do you have similar problems at refresh?

navigating in the different screens is a bit faster, i just dont know why the refresh takes so long.

you can have a look at it here - do you have similar problems with the fire10?


(Sebastian) #6

Hey @e36Alex,
I think my Fire 10 is faster. From starting the app until Habpanel is loaded with the welcome screen, it takes a second, I think.
Keep in mind that depending on the page you load, Habpanel queries OH for every single configured item to have the status. I would recommend using chrome toolbar and check where delays come from.
I swapped my Fire 7" to the 10" version. I might be able to compare startup speeds this weekend.


(Alexander) #7

thanks for your reply - it would be great, if you could benchmark the loading times. another thing is, that calling habpanel from habpanelviewer oder silkbrowser is much faster than the refresh at FKB.


(Mihai Badea) #8

I’m also using Fully Kiosk with it’s powerful REST API and I’d like to share my setup - not yet pinned to the wall, I’m waiting for something like this to arrive.
I’m gonna use a Acer Iconia One 10 (B3-A40) which has the ability to turn on the screen when double-tapping on it. This is very important for me as I’m gonna use the screensaver feature of Fully to display a slideshow of family photos only on interval 18:00-22:00 (12:00-22:00 in weekends) and, in the rest, the tablet will be with the screen off.
When it’s in “photoframe” mode a single touch is enough to go to OH UI and, when screen if off, a double-tap will be needed to wake the screen.
Also, when someone rings the doorbell, the tabel will wake up (or exit from screensaver), display a fedd fromt he fron door camera and announce, using Fully TSS, that Someone is at the front door.

To interface with OH I’m using the HTTP binding and HTTP actions.
HTTP binding is configure like below to refresh the deviceInfo:

# http.cfg
wallpanel_deviceInfo.url=http://wallpanel:2323/?pwd=XXXXX&cmd=deviceInfo&type=json
wallpanel_deviceInfo.updateInterval=1000

As the Fully screenBrightness accepts values in the [0…255] interval and a dimmer item from openHAB has [0…100] I wanted to transform between those two and I’m using a JS transformation and a rule - see details below.

wallpanel.items:

Group gWallpanel (All)

Number Wallpanel_batteryLevel "Battery [%d%%]" <battery> (gWallpanel) {http="<[wallpanel_deviceInfo:600000:JSONPATH($.batteryLevel)]"}
Switch Wallpanel_screenOn "Screen" <tablet> (gWallpanel) {http="<[wallpanel_deviceInfo:10000:JS(wallpanel_isScreenOn.js)] >[ON:POST:http://wallpanel:2323/?password=XXXXXX&cmd=screenOn] >[OFF:POST:http://wallpanel:2323/?password=XXXXXX&cmd=screenOff]"}
Dimmer Wallpanel_screenBrightness "Brightness [%d]" (gWallpanel) {http="<[wallpanel_deviceInfo:10000:JS(wallpanel_screenBrightness.js)]"}
Number Wallpanel_screenOffTimer "Screeensaver/OFF [%d s]" <tabletoff> (gWallpanel)

String Wallpanel_displayURL
String Wallpanel_TTS
Switch Wallpanel_Notification

wallpanel_isScreenOn.js:

(function(json){
    var deviceInfo = JSON.parse(json);
    if (deviceInfo.isScreenOn) {
        return 'ON';
     } else {
         return 'OFF';
     }
})(input)

wallpanel_screenBrightness.js:

(function(json){
    var deviceSettings = JSON.parse(json);
    return Math.round(parseInt(deviceSettings.screenBrightness) / 2.55);
})(input)

wallpanel.rules:

import java.net.URLEncoder

rule "Wallpanel_Schedule_photoFrameON"
when
    Time cron "0 0 18 ? * MON,TUE,WED,THU,FRI *" or
    Time cron "0 0 12 ? * SAT,SUN *"
then
    sendHttpPostRequest('http://wallpanel:2323/?password=XXXXX&cmd=setStringSetting&key=timeToScreenOffV2&value=0') 
    sendHttpPostRequest('http://wallpanel:2323/?password=XXXXX&cmd=setStringSetting&key=timeToScreensaverV2&value='+Wallpanel_screenOffTimer.state.toString)
    Wallpanel_screenOn.sendCommand(ON)
end

rule "Wallpanel_Schedule_photoFrameOFF"
when
    Time cron "	0 0 22 1/1 * ? *"
then
    sendHttpPostRequest('http://wallpanel:2323/?password=XXXXX&cmd=stopScreensaver') //exit screensaver
    sendHttpPostRequest('http://wallpanel:2323/?password=XXXXX&cmd=setStringSetting&key=timeToScreenOffV2&value='+Wallpanel_screenOffTimer.state.toString)
    sendHttpPostRequest('http://wallpanel:2323/?password=XXXXX&cmd=setStringSetting&key=timeToScreensaverV2&value=0')
    Wallpanel_screenOn.sendCommand(OFF)
end

rule "Wallpanel_Notification"
when
    Item Wallpanel_Notification changed to ON
then
    if(Wallpanel_displayURL.state != NULL){
        if(Wallpanel_screenOn.state != ON) {
            logWarn("DEBUG","Wallpanel - turning ON screen...")
            Wallpanel_screenOn.sendCommand(ON)
            Thread::sleep(250)
        }

        sendHttpPostRequest('http://wallpanel:2323/?password=XXXXXX&cmd=stopScreensaver')

        sendHttpPostRequest('http://wallpanel:2323/?password=XXXXX&cmd=loadURL&url=' + URLEncoder::encode(Wallpanel_displayURL.state.toString,'UTF-8'))
        Thread::sleep(100)
        Wallpanel_displayURL.postUpdate(NULL)
    }
    if(Wallpanel_TTS.state != NULL){
        sendHttpPostRequest('http://wallpanel:2323/?password=XXXXX&cmd=textToSpeech&text=' + Wallpanel_TTS.state.toString.replaceAll(" ","+"))
        Thread::sleep(100)
        Wallpanel_TTS.postUpdate(NULL)
    }
    Wallpanel_Notification.postUpdate(OFF)
end

rule "Wallpanel_screenBrightness"
when
    Item Wallpanel_screenBrightness received command
then
    val new_brightness = Math::round((Wallpanel_screenBrightness.state as Number).intValue * 2.55).intValue
    //logWarn("DEBUG","new_brightness = [" + new_brightness + "]")
    sendHttpPostRequest('http://wallpanel:2323/?password=XXXXXX&cmd=setStringSetting&key=screenBrightness&value=' + new_brightness)
end

The rules are pretty much self explanatory…
One thing I miss is the ability to set volume level through REST, but the developer said that maybe this would be added in a future release.


Http1 binding using a base url
(Klim Bim) #9

Did it arrive at the end? What is your experience with this magnet thing? Useful?

Cheers!


(Marc) #10

hi guys,

can you confirm this app also runs on the new fire tablet, they are now off for valentines day here:

what i want to have is motion detection - turn on when someone steps in front of panel - does this work?