mampfes / script.module.openhab

openHAB for Kodi
Other
11 stars 4 forks source link

Openhab 2 Support #2

Open bilakos opened 8 years ago

bilakos commented 8 years ago

Current version does not support Openhab 2. Any plans to make this Addon available for Openhabs new release ?

mampfes commented 8 years ago

Hi, sorry - I don't use Openhab 2 in my production system. Therefore I don't have a need (so far). But if I find some spare time I will try to get it running with Openhab 2.

Do you know if there are major differences regarding the REST API between Openhab and Openhab 2?

Best regards

Steffen

2016-04-17 15:04 GMT+02:00 bilakos notifications@github.com:

Current version does not support Openhab 2. Any plans to make this Addon available for Openhabs new release ?

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/mampfes/script.module.openhab/issues/2

Baumi1245 commented 7 years ago

Hi, i also need it for OH2... i could make screenshots of the REST API from OH2, if this helps.... so - just tell what exactly is needed.

Thank you

mampfes commented 7 years ago

Hi Thomas,

I'm quite busy at the moment (building 2 dormers onto my roof), therefore I don't have much spare time. But anything that helps me increases the chance that I can do something for OH2 :-)

Regards

Steffen

Baumi1245 commented 7 years ago

Hallo, danke für die Antwort.... Ich mach jetzt mal auf deutsch weiter - sonst wird das nichts.

Wenn du dir OH2 holst, hast du eine eigene Seite für die Rest-API, da sind alle Funktionen selbsterklärend - siehe hier: screenshot 19 Ich seh mir gerade den code von der openhab1.py an - weiß aber absolut nicht wo ich ansetzen könnte....

Baumi1245 commented 7 years ago

"name": "kodi", "label": "Kodi", "link": "http://192.168.125.60:8080/rest/sitemaps/kodi", "homepage": { "link": "http://192.168.125.60:8080/rest/sitemaps/kodi/kodi", "leaf": false, "widgets": [] }

return self.fetch_abs_json_url('http://%s:%s/rest%s' % (self.host, self.port, name), headers) das sollte im klartext doch http://192.168.125.60:8080/rest/sitemaps/kodi sein, oder? da bekomme ich 404 zurück http://192.168.125.60:8080/rest/sitemaps/kodi/kodi liefert was ab...

Ich hab leider oh1 nicht - bin bei oh2 frisch eingestiegen...

Baumi1245 commented 7 years ago

Debug vom auswählen der sitemap `11:07:06 T:1788 DEBUG: fetching json url=http://192.168.125.60:8080/rest/sitemaps, headers={'accept': 'application/json'} 11:07:06 T:1788 DEBUG: response for url=http://192.168.125.60:8080/rest/sitemaps, text=[{"name":"test","label":"test","link":"http://192.168.125.60:8080/rest/sitemaps/test","homepage":{"link":"http://192.168.125.60:8080/rest/sitemaps/test/test","leaf":false,"widgets":[]}},{"name":"weather","label":"Wetter","link":"http://192.168.125.60:8080/rest/sitemaps/weather","homepage":{"link":"http://192.168.125.60:8080/rest/sitemaps/weather/weather","leaf":false,"widgets":[]}},{"name":"kodi","label":"Kodi","link":"http://192.168.125.60:8080/rest/sitemaps/kodi","homepage":{"link":"http://192.168.125.60:8080/rest/sitemaps/kodi/kodi","leaf":false,"widgets":[]}},{"name":"_default","label":"Home","link":"http://192.168.125.60:8080/rest/sitemaps/_default","homepage":{"link":"http://192.168.125.60:8080/rest/sitemaps/_default/_default","leaf":false,"widgets":[]}}], headers={'Date': 'Mon, 07 Nov 2016 10:07:04 GMT', 'Content-Length': '771', 'Content-Type': 'application/json', 'Server': 'Jetty(9.2.14.v20151106)'} 11:07:06 T:1788 DEBUG: Previous line repeats 1 times. 11:07:06 T:1788 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--

mampfes commented 7 years ago

Hi, na zum Glück kann ich auch ein bisschen deutsch :-)

Bei mir liefert Openhab1 folgende Response:

22:02:49 T:5928  NOTICE: fetching json url=http://192.168.2.104:8080/rest/sitemaps, headers={'accept': 'application/json'}
22:02:49 T:5928  NOTICE: response for url=http://192.168.2.104:8080/rest/sitemaps, text={"sitemap":[{"name":"zuhause","label":"Hauptmen&#258;&#378;","link":"http://192.168.2.104:8080/rest/sitemaps/zuhause","homepage":{"link":"http://192.168.2.104:8080/rest/sitemaps/zuhause/demo","leaf":"false"}},{"name":"kodi","label":"kodi","link":"http://192.168.2.104:8080/rest/sitemaps/kodi","homepage":{"link":"http://192.168.2.104:8080/rest/sitemaps/kodi/kodi","leaf":"false"}}]}, headers={'Transfer-Encoding': 'chunked', 'Expires': '-1', 'Server': 'Jetty(8.1.3.v20120522)', 'X-Atmosphere-tracking-id': 'b19c671b-3bba-4c6b-87c4-5b5ddbd9aff8', 'Pragma': 'no-cache', 'Cache-Control': 'no-store, no-cache, must-revalidate', 'Date': 'Mon, 07 Nov 2016 21:02:50 GMT', 'Access-Control-Allow-Credentials': 'true', 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'}

Wie man sieht gibt es bei mir noch ein Hash mit dem Label "sitemap" bevor das Array mit den Sitemaps kommt. Bei Dir fehlt das. Vielleicht reicht es schon aus die Zeile 233 folgendermassen zu ändern:

< for i in as_array(result['sitemap']):
> for i in as_array(result):

Gruss

Steffen

Baumi1245 commented 7 years ago

Bei dem Namen wär´s schon seltsam, wenn du kein Deutsch könntest....

nein, leider war´s das nicht:

`09:24:56 T:3840 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--

mampfes commented 7 years ago

Dein Editor scheint die Einrückung durcheinander gebracht zu haben. Python ist da sehr empfindlich. Probier mal die angehängte Datei aus (gezippte openhab1.py). openhab1.zip

Baumi1245 commented 7 years ago

ja, jetzt geht´s danke! ich kann die sitemap wählen - es werden aber leider keine items angezeigt, auch keine fehlermeldung mehr.

ich hab zwar mit Notepad++ gearbeitet, die alte zeile aber auskommentiert drinnen gelassen - das könnte es gewesen sein...

Wie geht´s jetzt weiter?! Proxy ist auf system, keine login-daten nötig

Baumi1245 commented 7 years ago

so, ich habe kodi gestartet, dann das plugin. danach alles wieder beendet.

keine einträge in der sitemap - der log anbei kodi.zip

Baumi1245 commented 7 years ago

ich hab mal deinen und meinen response verglichen (und ein paar nullen bei der url und leerzeichen zum abgleichen eingefügt):

22:02:49 T:5928  NOTICE: fetching json url=http://192.168.2.104:8080/rest/sitemaps, headers={'accept': 'application/json'}
12:37:43 T:8968   DEBUG: fetching json url=http://127.000.0.001:8080/rest/sitemaps, headers={'accept': 'application/json'}

22:02:49 T:5928  NOTICE: response for url=http://192.168.2.104:8080/rest/sitemaps, text={"sitemap":[{"name":"zuhause","label":"Hauptmen&#258;&#378;","link":"http://192.168.2.104:8080/rest/sitemaps/zuhause","homepage":{"link":"http://192.168.2.104:8080/rest/sitemaps/zuhause/demo","leaf":"false"}},           {"name":"kodi",   "label":"kodi",  "link":"http://192.168.2.104:8080/rest/sitemaps/kodi","homepage":{"link":"http://192.168.2.104:8080/rest/sitemaps/kodi/kodi",  "leaf":"false"}}]},                                                                                                                                                                                                          headers={'Transfer-Encoding': 'chunked', 'Expires': '-1', 'Server': 'Jetty(8.1.3.v20120522)', 'X-Atmosphere-tracking-id': 'b19c671b-3bba-4c6b-87c4-5b5ddbd9aff8', 'Pragma': 'no-cache', 'Cache-Control': 'no-store, no-cache, must-revalidate', 'Date': 'Mon, 07 Nov 2016 21:02:50 GMT', 'Access-Control-Allow-Credentials': 'true', 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'}
12:37:43 T:8968   DEBUG: response for url=http://127.000.0.001:8080/rest/sitemaps, text=           [{"name":"test",   "label":"test",                "link":"http://127.0.0.1:8080/rest/sitemaps/test",       "homepage":{"link":"http://127.0.0.1:8080/rest/sitemaps/test/test",       "leaf":false,"widgets":[]}},{"name":"weather","label":"Wetter","link":"http://127.0.0.1:8080/rest/sitemaps/weather", "homepage":{"link":"http://127.0.0.1:8080/rest/sitemaps/weather/weather","leaf":false,"widgets":[]}},{"name":"_default","label":"Home","link":"http://127.0.0.1:8080/rest/sitemaps/_default","homepage":{"link":"http://127.0.0.1:8080/rest/sitemaps/_default/_default","leaf":false,"widgets":[]}}], headers={'Date': 'Thu, 10 Nov 2016 11:37:43 GMT', 'Content-Length': '556', 'Content-Type': 'application/json', 'Server': 'Jetty(9.2.14.v20151106)'}

Kann man damit was anfangen?

mampfes commented 7 years ago

Hi Thomas, ich hab in der Zwischenzeit etwas Fortschritte gemacht (die Sitemap wird wieder angezeigt) allerdings funktionieren noch nicht alle Controls. Ich melde mich wieder wenn ich weitere Infos habe.

mampfes commented 7 years ago

Hi, mit der angehängten Version funktioniert die OpenHAB2 Demo Sitemap wieder. Kannst Du mal ausprobieren ob es bei Dir auch funktioniert? script.module.openhab.zip

Baumi1245 commented 7 years ago

Besser, aber noch nicht gut ;-) die _default Sitemap geht - die anderen noch nicht...

anbei der log kodi.zip

mampfes commented 7 years ago

Hi, sorry - bin die letzten 2 Wochen zu nichts gekommen. Hab mir jetzt aber mal Dein Log angeschaut. Deine Sitemap hat folgende Switches unter dem Frame "Wohnzimmer" die mit keinem Item verknüpft sind: "3er-LED", "8er-LED", "frei". Dito für Frame "PC Kinder": "BĂźrolicht", "8er-LED". Wenn Du die aus der Sitemap rausnimmst sollte sie richtig angezeigt werden. Gibt es einen speziellen Grund warum Du Switches ohne Items definiert hast? Das kann doch keine Funktion haben, oder_

Baumi1245 commented 7 years ago

Dachte, das macht nichts aus - da ja z.B. HABdroid da trotzdem was anzeigt. Ja, es gibt gründe - helfe beim debuggen vom Syno-Installer mit da hab ich OH2 schon mindestens 20x installiert... und im schlechtesten fall nur mehr das nötigste wieder aktiviert, darum.

ich räume dann auf und versuche nochmal - danke für den Tipp!

mampfes commented 7 years ago

OK. Ich dachte mir schon dass das was Temporäres ist. Aber wenn andere UI's dies einfach ignorieren sollte ich das wohl besser auch tun...

Baumi1245 commented 7 years ago

So - läuft.... Interessant ist vielleicht auch noch, daß bei einer andern Baustellen-Sitemap doch etwas angezeigt wurde. Aber ignorieren lassen ist sicher nicht schlechter - dann würde bei solchen fällen ein einfaches "läuft es denn in der Basic-UI?" der fehler schnell eingrenzen lassen.

TOP!

Baumi1245 commented 7 years ago

...jetzt wird´s kitschig. Bisher hab ich kodi und dein addon unter Win10 getestet.

habe gerade die alpha auf android TV raufgemacht - da kann ich zwar die sitemaps einlesen, es wird aber nichts dargestellt. anbei nochmal die logs. kodi.zip

danke

mampfes commented 7 years ago

Oha, anscheinend läuft auf Android TV eine ältere (d.h. < 2.7) Version von Python. Das Addon braucht aber min. 2.7. Ich hab eine Version gebaut die theoretisch (ich kann's leider nicht testen) auch mit 2.6 läuft. Kannst Du die mal ausprobieren? script.module.openhab.zip

Baumi1245 commented 7 years ago

leider läßt sich schon die sitemap nicht mehr laden:

11:29:51 T:18446744071990733104   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.ImportError'>
                                            Error Contents: No module named ordereddict
                                            Traceback (most recent call last):
                                              File "/storage/emulated/10/Android/data/org.xbmc.kodi/files/.kodi/addons/script.module.openhab-master/default.py", line 9, in <module>
                                                import resources.lib.openhab2 as openhab2
                                              File "/storage/emulated/10/Android/data/org.xbmc.kodi/files/.kodi/addons/script.module.openhab-master/resources/lib/openhab2.py", line 8, in <module>
                                                from ordereddict import OrderedDict
                                            ImportError: No module named ordereddict
                                            -->End of Python script error report<--
11:31:57 T:18446744071992121648   ERROR: Previous line repeats 1 times.
mampfes commented 7 years ago

Oje, Anfängerfehler von mir: Ich hab vergessen eine neue Datei einzuchecken. Kannst Du es bitte nochmal probieren? Danke! script.module.openhap.zip

Baumi1245 commented 7 years ago

leider läßt es sich jetzt nicht mehr installieren:

10:44:44 T:18446744071919556912   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.ImportError'>
                                            Error Contents: No module named ordereddict
                                            Traceback (most recent call last):
                                              File "/storage/emulated/10/Android/data/org.xbmc.kodi/files/.kodi/addons/script.module.openhab-master/default.py", line 9, in <module>
                                                import resources.lib.openhab2 as openhab2
                                              File "/storage/emulated/10/Android/data/org.xbmc.kodi/files/.kodi/addons/script.module.openhab-master/resources/lib/openhab2.py", line 8, in <module>
                                                from ordereddict import OrderedDict
                                            ImportError: No module named ordereddict
                                            -->End of Python script error report<--
10:45:28 T:18446744072427194672   ERROR: Previous line repeats 1 times.
zwieja commented 7 years ago

@mampfes Raspberry PI 3 Openhab 2.0 Snapshot Build #623 Latest OSMC

Error during addon startup

DEBUG: CPythonInvoker(25, /home/osmc/.kodi/addons/script.module.openhab-1.0.2/default.py): start processing 12:48:11 6437.919922 T:1761154032 DEBUG: -->Python Interpreter Initialized<-- 12:48:11 6437.919922 T:1761154032 DEBUG: CPythonInvoker(25, /home/osmc/.kodi/addons/script.module.openhab-1.0.2/default.py): the source file to load is "/home/osmc/.kodi/addons/script.module.openhab-1.0.2/default.py" 12:48:11 6437.920410 T:1761154032 DEBUG: CPythonInvoker(25, /home/osmc/.kodi/addons/script.module.openhab-1.0.2/default.py): setting the Python path to /home/osmc/.kodi/addons/script.module.openhab-1.0.2:/home/osmc/.kodi/addons/script.module.requests/lib:/usr/lib/python2.7:/usr/lib/python2.7/plat-arm-linux-gnueabihf:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload:/usr/local/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages/PILcompat:/usr/lib/python2.7/dist-packages/gtk-2.0 12:48:11 6437.920410 T:1761154032 DEBUG: CPythonInvoker(25, /home/osmc/.kodi/addons/script.module.openhab-1.0.2/default.py): entering source directory /home/osmc/.kodi/addons/script.module.openhab-1.0.2 12:48:11 6437.920410 T:1761154032 DEBUG: CPythonInvoker(25, /home/osmc/.kodi/addons/script.module.openhab-1.0.2/default.py): instantiating addon using automatically obtained id of "script.module.openhab" dependent on version 2.24.0 of the xbmc.python api 12:48:13 6439.360352 T:1761154032 DEBUG: fetching json url=http://192.168.0.15:8080/rest/sitemaps, headers={'accept': 'application/json'} 12:48:13 6439.680176 T:1761154032 DEBUG: response for url=http://192.168.0.15:8080/rest/sitemaps, text=[{"name":"demo","label":"Main Menu","link":"http://192.168.0.15:8080/rest/sitemaps/demo","homepage":{"link":"http://192.168.0.15:8080/rest/sitemaps/demo/demo","leaf":false,"widgets":[]}},{"name":"_default","label":"Home","link":"http://192.168.0.15:8080/rest/sitemaps/_default","homepage":{"link":"http://192.168.0.15:8080/rest/sitemaps/_default/_default","leaf":false,"widgets":[]}}], headers={'Date': 'Thu, 08 Dec 2016 11:48:06 GMT', 'Content-Length': '384', 'Content-Type': 'application/json', 'Server': 'Jetty(9.2.14.v20151106)'} 12:48:13 6439.683594 T:1761154032 DEBUG: Previous line repeats 1 times. 12:48:13 6439.683594 T:1761154032 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--

  • NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS! Error Type: <type 'exceptions.TypeError'> Error Contents: list indices must be integers, not str Traceback (most recent call last): File "/home/osmc/.kodi/addons/script.module.openhab-1.0.2/default.py", line 200, in show_sitemaps() File "/home/osmc/.kodi/addons/script.module.openhab-1.0.2/default.py", line 186, in show_sitemaps sitemaps = sorted(oh.load_sitemaps().iterkeys()) File "/home/osmc/.kodi/addons/script.module.openhab-1.0.2/resources/lib/openhab1.py", line 233, in load_sitemaps for i in as_array(result['sitemap']): TypeError: list indices must be integers, not str -->End of Python script error report<--
mampfes commented 7 years ago

Hi, please excuse the delay. Version 1.0.2 is not compatible with OpenHAB2. Here is a beta version that should work with OpenHAB2. @Baumi1245: Diese Version sollte wieder funktionieren. Ich hab letztes Mal leider direkt das zip File von github verwendet was so nicht funktioniert. script.module.openhab.zip

Baumi1245 commented 7 years ago

rennt! es wurde gleich die letzte config verwendet und lichter schalten....

ist es auch möglich das plugin direkt auf eine taste zu mappen? so in etwa: <blue>XBMC.RunPlugin(plugin://plugin.video.surveillanceroom?action=show_preview&camera_number=4)</blue>

Baumi1245 commented 7 years ago

so, erste test durchgeführt; was mir aufgefallen ist:

ob es jetzt an der OH2-Variante liegt kann ich natürlich nicht sagen;

Jedenfalls ein fettes DANKE, daß es überhaupt läuft!

EDIT: visibility=[] geht jetzt - vermutlich wurde die sitemap nicht aktuallisiert.....

mampfes commented 7 years ago

Vielen Dank für Dein Feedback!

Baumi1245 commented 7 years ago
zwieja commented 7 years ago

@mampfes

What is the status of the script module for openhab 2 ?

mampfes commented 7 years ago

@zwieja : Github master should work with openhab 2 (or use the zip file in one of my last posts - but this one doesn't support openhab 1 and 2 at once).

zwieja commented 7 years ago

@mampfes I can confirm that this addon works for Windows version of Kodi. But..

I have problem to install this addon on Raspberry 3 with Kodi. When I want to install I have info about unresolved dependencies and that I need contact with the autor.

Problem solved with installation on Raspberry 3.

Addon have display problems with SetPoint items and Group Items.

mampfes commented 7 years ago

@zwieja : Ok, thanks for the info. Can you send me screenshots?

RobertKitzing commented 7 years ago

v17 (Krypton) will work if you change in addon.xml "xbmc.gui" to 5.12

Sisko1sk commented 7 years ago

There is also a version for openelec 6.0.3 (on raspberry3)? The old version I can to install, but version for OH2 from mampfes during installation report bugs (unresolved dependencies).

mampfes commented 7 years ago

@Sisko1sk : could you post the missing dependencies?

Sisko1sk commented 7 years ago

DEBUG: CAddonInstallJob[script.module.openhab]: requires xbmc.python version 2.24.0 which is not available

mampfes commented 7 years ago

Hi, thanks for the infos. I released revision 2.0.0 with krypton and openhab2 support. Note: Depending on your skin there may be too much transparency and the background shines through. Did not find the time to correct this, any help is appreciated.

Sisko1sk commented 7 years ago

Sorry, but I cannot find this revision. Where I find this version?

mampfes commented 7 years ago

@Sisko1sk : https://github.com/mampfes/script.module.openhab/releases/download/V2.0.0/script.module.openhab.zip