as @rossko57 already noted i do this very often in sitemap to prevent accidentally clicks.
see a rough overview (i work with jython):
the (proxy)-item in items-file
Number iViReset_OpenHAB
the sitemap:
Switch item=iViReset_OpenHAB label="OpenHAB & 1Wire" icon="error" labelcolor=["black"] mappings=[1="! Reset !"] visibility=[iViReset_OpenHAB==0]
Switch item=iViReset_OpenHAB label="Reset OpenHAB & 1Wire?" icon="confirm" labelcolor=["red"] mappings=[2="bestätigen", 3="abbrechen"] visibility=[iViReset_OpenHAB==1]
Text item=iViReset_OpenHAB label="Reset OpenHAB & 1Wire[! ausgefĂĽhrt !]" icon="alarm" labelcolor=["red"] visibility=[iViReset_OpenHAB==2]
the py-file:
def confirm_function(item, befehl):
retval = False
if befehl == 1:
postUpdateCheckFirst(item, "1") # postUpdate manuell ausfĂĽhren falls autoupdate="false"
elif befehl == 2:
LogAction.logInfo(u"confirm_function", u"Bestätigt Funktion Item %s" % item)
retval = True
elif befehl == 3:
LogAction.logInfo(u"confirm_function", u"Abbruch Funktion Item %s" % item)
sleep(0.1)
postUpdate(item, "0")
elif befehl == 5:
postUpdateCheckFirst(item, "5") # postUpdate manuell ausfĂĽhren falls autoupdate="false"
elif befehl == 6:
LogAction.logInfo(u"confirm_function", u"Bestätigt Funktion Item %s" % item)
retval = True
elif befehl == 7:
LogAction.logInfo(u"confirm_function", u"Abbruch Funktion Item %s" % item)
sleep(0.1)
postUpdate(item, "4")
elif befehl == 9:
postUpdateCheckFirst(item, "9") # postUpdate manuell ausfĂĽhren falls autoupdate="false"
elif befehl == 10:
LogAction.logInfo(u"confirm_function", u"Bestätigt Funktion Item %s" % item)
retval = True
elif befehl == 11:
LogAction.logInfo(u"confirm_function", u"Abbruch Funktion Item %s" % item)
sleep(0.1)
postUpdate(item, "0")
elif befehl == 13:
postUpdateCheckFirst(item, "13") # postUpdate manuell ausfĂĽhren falls autoupdate="false"
elif befehl == 14:
LogAction.logInfo(u"confirm_function", u"Bestätigt Funktion Item %s" % item)
retval = True
elif befehl == 15:
LogAction.logInfo(u"confirm_function", u"Abbruch Funktion Item %s" % item)
sleep(0.1)
postUpdate(item, "12")
return retval
@rule("Init Technik",\
description="Initialisierungen beim Systemstart verzögert ausführen",\
tags=["Systemstart"])
@when("System started")
def init_technik(event):
postUpdate("iViReset_OpenHAB", "0")
# **********************************************************
# *** Reset Raspberry Pi (Openhab)
# **********************************************************
def reset_openhab_body():
postUpdate("iViReset_OpenHAB", "0")
LogAction.logInfo(u"iJython_Busbefehl", u"Aktor 1/10 fĂĽr 10 Sekunden aktiviert - Reset Raspberry & 1wire")
sendCommand("iJython_Busbefehl", "*#1*0110#4#01*#2*0*0*10##") # Aktor 1/10 fĂĽr 10 Sekunden aktiviert - Reset Raspberry & 1wire
@rule("Reset Openhab",\
description=u"Reset Raspberry Pi (Openhab), incl. SicherheitsrĂĽckfrage")
@when("Item iViReset_OpenHAB received command")
def reset_openhab(event):
item = event.itemName
befehl = event.itemCommand.intValue()
if confirm_function(item, befehl):
ScriptExecution.createTimer(DateTime.now().plusSeconds(5), reset_openhab_body)
i want to add that i use the confirm_function quite often, because of that it uses more commands as needed for this example.
i think this is surely not the best solution, but for me it works quite good, maybe at least it points you a direction