Befehle von Kodi Lirc an FHEM

Begonnen von Hofi15, 27 März 2018, 12:11:06

Vorheriges Thema - Nächstes Thema

Hofi15

Hallo,

Nach dem ich mich wieder mal einige zeit mit dem Thema Kodi und Lirc beschäftigt habe. Möchte ich euch meine neuen Erkenntnisse nicht vorenthalten. Vielleicht kann sich ja jemand darüber freuen.

Ich Verwende:
Raspberry Pi 3
Libreelec v8.2.4
lirc v0.9.4d

Aufgabe:
Ich möchte mit einer IR-Fernbedienung gesendete Code über kodi an FHEM senden. In FHEM soll in meinem Fall später eine Überwachung entstehen. Dieser soll auswerten wie lange der letzte Tastendruck her ist und wenn dieser einer vorgegeben Zeit her ist den TV abschalten.

Funktion
Die IR-Signale werden von einem IR-Empfänger welcher am GPIO angeschlossen ist empfangen.
Lirc verarbeitet die Signal und macht daraus lesbare Code mittels lircd.conf
Die Lesbaren Code sollen keine Standardbefehle in Kodi ausführen.
Die Code sollen via eventmap Shell Scripte aufrufen.
Diese Shell Scripte senden Befehle via Telnet an FHEM

Voraussetzungen
In FHEM ist der Telnetport angelegt. In meinem Fall 7020 mit Passwort
Libreelec ist auf einem anderen gerät installiert. In meinem Fall auf dem Raspberry 3
In Libreelec ist die folgende option aktiviert. Einstellungen>LibreELEC>Dienste>Lirc>Lirc aktivieren = 1
In Libreelec ist die folgende option aktiviert. Einstellungen>LibreELEC>Dienste>SSH>SSH aktivieren = 1

Dateien mit Inhalten in LibreELEC mit SSH anlegen:
/storage/.config/lircd.conf  (Achtung hier muss eure Fernbedienung angelegt werden. Der Link wie das geht folgt)

begin remote

  name  SAMSUNGTV
  bits           16
  flags SPACE_ENC|CONST_LENGTH
  eps            30
  aeps          100

  header       4476  4519
  one           524  1711
  zero          524   593
  ptrail        518
  pre_data_bits   16
  pre_data       0xE0E0
  gap          107718
  min_repeat      1
#  suppress_repeat 1
#  uncomment to suppress unwanted repeats
  toggle_bit_mask 0x7E7E

      begin codes
          KEY_F1    0x20DF   #1
          KEY_F2    0xA05F   #2
      end codes

end remote



/storage/.kodi/userdata/Lircmap.xml (hier werden die Angelegten Code von lircd.conf gemappt)


<?xml version="1.0" encoding="UTF-8"?>
<!-- This file contains the mapping of LIRC keys to XBMC keys used in Keymap.xml  -->
<!--                                                                              -->
<!-- How to add remotes                                                           -->
<!-- <remote device="name_Lirc_calls_the_remote">                                 -->
<!--                                                                              -->
<!-- For the commands the layout following layout is used                         -->
<!-- <XBMC_COMMAND>LircButtonName</XBMC_COMMAND>                                  -->
<!--                                                                              -->
<!-- For a list of XBMC_COMMAND's check out the <remote> sections of keymap.xml   -->

<lircmap>
<remote device="devinput">
<obc1>KEY_F1</obc1>
<obc2>KEY_F2</obc2>

</remote>
</lircmap>



/storage/.kodi/userdata/keymaps/remote.xml

<?xml version="1.0" encoding="UTF-8"?>
<!-- This file contains the mapping of remote keys to actions within Kodi.                -->
<!--                                                                                      -->
<!-- The format is:                                                                       -->
<!--  <window>                                                                            -->
<!--    <device>                                                                          -->
<!--      <button>action</button>                                                         -->
<!--    </device>                                                                         -->
<!--  </window>                                                                           -->
<!--                                                                                      -->
<!-- The <global> section is a fall through - they will only be used if the button is     -->
<!-- not used in the current window's section.                                            -->
<!--                                                                                      -->
<!-- Actions can be built-in functions.                                                   -->
<!--  eg <B>ActivateWindow(Music)</B>                                                     -->
<!-- would automatically go to Music on the press of the B button.                        -->
<!--                                                                                      -->
<!-- An empty action removes the corresponding mapping from default and parent keymaps.   -->
<!-- This is different from a "noop" action, which disables a button.                     -->
<!--                                                                                      -->
<!-- More documentation on keymaps can be found on http://kodi.wiki/view/keymaps          -->
<keymap>
  <global>
    <remote>
    </remote>
    <universalremote>
      <obc1>System.Exec("/storage/.kodi/userdata/tastenscripte/obc1.sh")</obc1>
      <obc2>System.Exec("/storage/.kodi/userdata/tastenscripte/obc2.sh")</obc2>
    </universalremote>
  </global>
</keymap>



/storage/.kodi/userdata/tastenscripte/obc1.sh                /storage/.kodi/userdata/tastenscripte/obc2.sh  (diese Dateien müsst ihr ausführbar machen)

#!/bin/sh
# This is a comment!
echo -en "PASSWORT\nsetreading FHEMDEVICE state KEY01\nquit\n" |  /bin/nc -w5 FHEMip 7072


Bei PASSWORT muss das Passwort von eure Telnet-Verbindung welches ihr in FHEM angelegt habt eingegeben werden. Bei FHEMDEVICE muss der der Device angegeben werden welcher die Tastencode erhalen soll. Bei FHEMip muss die ip Adresse von eurem FHEM angegeben werden

Nach dem alles angelegt ist müsst ihr nur noch euer LibreElec mit reboot neu starten.
MFG Hofi

Wenn ich etwas vergessen habe oder etwas falsch ist dann könnt ihr mir das gerne mitteilen.

Hofi15

Hallo,

Mir ist heute aufgefallen das es obc (OriginalButtonCode) Nummern gibt die Kodi schon für etwas verwendet und dann kann es zu Problemen kommen. Ich werde hier eine List anlegen in der man herausfinden kann welche obc Nummern verfügbar sind. In meinem Fall teste ich das mit der IR Fernbedienung über den IR Empfänger, mit der IR Fernbedienung über den CEC Samsung TV und mit der APP Yatse.

Die obc# gehen von 0-255.
Ich werde in der Liste wie folgt Markierungen machen. x=getestet und reserviert für Kodi; y= getestet und frei; z= nicht getestet


obc1 z
obc2 z
obc3 z
obc4 z
obc5 z
obc6 x
obc7 z
obc8 z
obc9 z
obc10 z
obc11 z
obc12 z
obc13 z
obc14 z
obc15 z
obc16 z
obc17 z
obc18 z
obc19 z
obc20 z
obc21 z
obc22 z
obc23 z
obc24 z
obc25 z
obc26 z
obc27 z
obc28 z
obc29 z
obc30 z
obc31 z
obc32 z
obc33 z
obc34 z
obc35 z
obc36 z
obc37 z
obc38 z
obc39 z
obc40 z
obc41 z
obc42 z
obc43 z
obc44 z
obc45 z
obc46 z
obc47 z
obc48 z
obc49 z
obc50 z
obc51 z
obc52 z
obc53 z
obc54 z
obc55 z
obc56 z
obc57 z
obc58 z
obc59 z
obc60 z
obc61 z
obc62 z
obc63 z
obc64 z
obc65 z
obc66 z
obc67 z
obc68 z
obc69 z
obc70 z
obc71 z
obc72 z
obc73 z
obc74 z
obc75 z
obc76 z
obc77 z
obc78 z
obc79 z
obc80 z
obc81 z
obc82 z
obc83 z
obc84 z
obc85 z
obc86 z
obc87 z
obc88 z
obc89 z
obc90 z
obc91 z
obc92 z
obc93 z
obc94 z
obc95 z
obc96 z
obc97 z
obc98 z
obc99 z
obc100 z
obc101 z
obc102 z
obc103 z
obc104 z
obc105 z
obc106 z
obc107 z
obc108 z
obc109 z
obc110 z
obc111 z
obc112 z
obc113 z
obc114 z
obc115 z
obc116 z
obc117 z
obc118 z
obc119 z
obc120 z
obc121 z
obc122 z
obc123 z
obc124 z
obc125 z
obc126 z
obc127 z
obc128 z
obc129 z
obc130 z
obc131 z
obc132 z
obc133 z
obc134 z
obc135 z
obc136 z
obc137 z
obc138 z
obc139 z
obc140 z
obc141 z
obc142 z
obc143 z
obc144 z
obc145 z
obc146 z
obc147 z
obc148 z
obc149 z
obc150 z
obc151 z
obc152 z
obc153 z
obc154 z
obc155 z
obc156 z
obc157 z
obc158 z
obc159 z
obc160 z
obc161 z
obc162 z
obc163 z
obc164 z
obc165 z
obc166 z
obc167 z
obc168 z
obc169 z
obc170 z
obc171 z
obc172 z
obc173 z
obc174 z
obc175 z
obc176 z
obc177 z
obc178 z
obc179 z
obc180 z
obc181 z
obc182 z
obc183 z
obc184 z
obc185 z
obc186 z
obc187 z
obc188 z
obc189 z
obc190 z
obc191 z
obc192 z
obc193 z
obc194 z
obc195 z
obc196 z
obc197 z
obc198 z
obc199 z
obc200 y
obc201 y
obc202 y
obc203 y
obc204 y
obc205 y
obc206 y
obc207 y
obc208 y
obc209 y
obc210 y
obc211 y
obc212 y
obc213 y
obc214 y
obc215 y
obc216 y
obc217 y
obc218 y
obc219 y
obc220 y
obc221 y
obc222 y
obc223 y
obc224 y
obc225 y
obc226 y
obc227 y
obc228 y
obc229 y
obc230 y
obc231 y
obc232 y
obc233 y
obc234 y
obc235 y
obc236 y
obc237 y
obc238 y
obc239 y
obc240 y
obc241 y
obc242 y
obc243 y
obc244 x
obc245 y
obc246 y
obc247 y
obc248 y
obc249 y
obc250 z
obc251 z
obc252 z
obc253 z
obc254 z
obc255 z



Wer etwas zur Liste beitragen möchte der gibt mir bescheid.

LG Hofi