Read GPIO state ,use it to change icon (switch)

  • Platform information:
    • Hardware: RPI0
    • OS: Raspbian GNU/Linux 8 (jessie)
    • Java Runtime Environment: Zulu Embedded
    • openHAB version:2.2
  • Issue of the topic:
    I have heating managment allready runing on pi0 , now I just want OH2 to read gpio state and present it as on/off icon (green/red io ) in basic UI just for info purpose so I’ve created a sript that reads gpio state , transform it from 0,1 to on/off but cant make icon to change state probably because exec:command outputs string.

Is it possible to make icons change state and how to do it ?

  • Please post configurations (if applicable):
    • Items configuration related to the issue
String   FF_KidsRoom_Heating  "Grejanje [MAP(]" <switch>{channel="exec:command:gpio_decija:output"}
  • Sitemap configuration related to the issue
Default item=FF_KidsRoom_Heating label="Decija"

Exec:command executes script to read gpio state

raspi-gpio get $1 | cut -c16

Map file is simple transform no issue there

Thanks . Goran

Maybe using the gpio binding is easier?

Or as i read Skript i think an other solution is using the exec binding and transformation. Maybe you might find some helpfull infos in the following tutorials.

I looked at gpio binding but I think its too agresive ie setting startup initial values etc, setting input output pins , exporting on exit etc …basically binding designed to control pins…but I allready have subsys in control of them that is raspi image based so any real interfering will probably brake something thats why I opted for readonly status…

Nevertheless I do get number value of gpio pin 1 and 0 but how to make it control the icon is still eluding me