43 lines
1.1 KiB
Text
43 lines
1.1 KiB
Text
|
import org.eclipse.smarthome.model.script.ScriptServiceUtil
|
||
|
// import org.eclipse.smarthome.core.library.items.StringItem
|
||
|
|
||
|
val mqttActions = getActions("mqtt", "mqtt:broker:mainBroker")
|
||
|
val TAG_FileName = "battlefield.rules"
|
||
|
|
||
|
|
||
|
rule "Démarrage de openHAB"
|
||
|
when
|
||
|
System started
|
||
|
then
|
||
|
logInfo(TAG_FileName, "Rule : Démarrage de openHAB")
|
||
|
// il n'y a personne dans la pièce et l'éclairage est fermé
|
||
|
mqttActions = getActions("mqtt", "mqtt:broker:mainBroker")
|
||
|
|
||
|
animation_toggle.sendCommand(ON)
|
||
|
end
|
||
|
|
||
|
rule "light toggle"
|
||
|
when
|
||
|
Item animation_toggle received command
|
||
|
then
|
||
|
logInfo(TAG_FileName, "Rule : mqtt evts")
|
||
|
logInfo(TAG_FileName, "item animation_toggle changed to " +
|
||
|
animation_toggle.state)
|
||
|
|
||
|
mqttActions.publishMQTT("lumiere/degat/toggle",
|
||
|
animation_toggle.state.toString(), false)
|
||
|
end
|
||
|
|
||
|
|
||
|
rule "light animation"
|
||
|
when
|
||
|
Item animation received command
|
||
|
then
|
||
|
logInfo(TAG_FileName, "Rule : mqtt evts")
|
||
|
logInfo(TAG_FileName, "item animation changed to " +
|
||
|
animation.state)
|
||
|
|
||
|
mqttActions.publishMQTT("lumiere/degat/animation",
|
||
|
animation.state.toString(), false)
|
||
|
end
|