Ich habe einen RasperyPi4b wo openHAB 4.2.1 läuft. Weiters läuft auf dem Raspi noch Mosquitto.
Ich betreibe mit einem Shellyplus I4 Taster zwei Rollläden welche über zwei Shellyplus2PM über Rules betrieben werden.
Meine Rules funktionieren das habe ich getestet, von einer openHAB-page wo ich die Rules Triggere.
Ich habe mich mit meinem Laptop und mqtt-Explorer mit dem Mosquitto-Broker verbunden, und konnte feststellen, dass die Meldungen vom I4-Taster rein kommen.
meine Rule
Code: Alles auswählen
configuration: {}
triggers:
- id: "1"
configuration:
thingUID: shelly:shellyplusi4:90380c35e7f4
event: SHORT_PRESSED
channelUID: shelly:shellyplusi4:90380c35f97c:status2#button
type: core.ChannelEventTrigger
conditions: []
actions:
- inputs: {}
id: "2"
configuration:
blockSource: <xml xmlns="https://developers.google.com/blockly/xml"><block
type="mediatech15:documentation_utilities_FreeNote"
id="GsP.Pl=4Oi_%M1}k7.8N" x="249" y="53"><field name="TEXT1">Rollladen
Nordseite runter</field></block><block type="controls_if"
id="s_6BB(nWW2l`Z@vz59@;" x="208" y="129"><mutation elseif="1"
else="1"></mutation><value name="IF0"><block type="logic_compare"
id="#%yl=.R1xBHkA9oxETlN"><field name="OP">EQ</field><value
name="A"><block type="oh_getitem_state" id="B1YK2VJ5aq*zR65w4maY"><value
name="itemName"><shadow type="oh_item"
id="024*=[Fn/|iQ62AQ[zB3"><mutation itemName="MyItem"
itemLabel="MyItem"></mutation><field
name="itemName">MyItem</field></shadow><block type="oh_item"
id="dsh*vB}/CX)+4Ij(DQl)"><mutation
itemName="SZ_Generic_MQTT_Thing_FensterNordseite"
itemLabel="Fenster-Nordseite"></mutation><field
name="itemName">SZ_Generic_MQTT_Thing_FensterNordseite</field></block></value></block></value><value
name="B"><block type="text" id="VkcGwF=$;A*FP(9}bNct"><field
name="TEXT">opening</field></block></value></block></value><statement
name="DO0"><block type="mqtt_publish" id="d%Fn`_D7_#Fh)2FN96to"><field
name="RETAIN">FALSE</field><value name="MESSAGE"><shadow type="text"
id="qzj3LWx^fLmqN@V}LB$+"><field
name="TEXT">message</field></shadow><block type="text"
id=")o:DhO0f0$j1eR{_I*h^"><field
name="TEXT">stop</field></block></value><value name="TOPIC"><shadow
type="text" id="2lfbm=XjVArjH6V?[^_G"><field
name="TEXT">topic</field></shadow><block type="text"
id="V(]igP];u)SP@VxPKk;/"><field
name="TEXT">shellyplus2pm-30c9228107f8/command/cover:0</field></block></value><value
name="BROKER"><shadow type="oh_thing" id="]|67BV4xtPYO{:s%s0|D"><field
name="thingUid">MyThing</field></shadow><block type="oh_thing"
id="d5}q(Gw0yBc9b^j$9ZuL"><field
name="thingUid">mqtt:broker:f4a9aa0fcc</field></block></value></block></statement><value
name="IF1"><block type="logic_compare" id="~1*a3Ud}zKKGMk4$?4Je"><field
name="OP">EQ</field><value name="A"><block type="oh_getitem_state"
id="J+tCtJkNJ[/[K^-y]rjk"><value name="itemName"><shadow type="oh_item"
id="oIsCcR$agFR}t~P$XyKn"><mutation itemName="MyItem"
itemLabel="MyItem"></mutation><field
name="itemName">MyItem</field></shadow><block type="oh_item"
id="4wpot`|sOpu[(|lwZ!ZJ"><mutation
itemName="SZ_Generic_MQTT_Thing_FensterNordseite"
itemLabel="Fenster-Nordseite"></mutation><field
name="itemName">SZ_Generic_MQTT_Thing_FensterNordseite</field></block></value></block></value><value
name="B"><block type="text" id="dl1`=~G^Ev3(:Q$0#[D+"><field
name="TEXT">closing</field></block></value></block></value><statement
name="DO1"><block type="mqtt_publish" id="`Ov;{TSUiu!-EBJT:_GF"><field
name="RETAIN">FALSE</field><value name="MESSAGE"><shadow type="text"
id="qzj3LWx^fLmqN@V}LB$+"><field
name="TEXT">message</field></shadow><block type="text"
id="wWFD`u2-]5(3$Ord+t!S"><field
name="TEXT">stop</field></block></value><value name="TOPIC"><shadow
type="text" id="2lfbm=XjVArjH6V?[^_G"><field
name="TEXT">topic</field></shadow><block type="text"
id="l,Dw+G;%#Gt2QZTg+.Z_"><field
name="TEXT">shellyplus2pm-30c9228107f8/command/cover:0</field></block></value><value
name="BROKER"><shadow type="oh_thing" id="]|67BV4xtPYO{:s%s0|D"><field
name="thingUid">MyThing</field></shadow><block type="oh_thing"
id=":RzVDb?Gi=9O3Q8jMx;h"><field
name="thingUid">mqtt:broker:f4a9aa0fcc</field></block></value></block></statement><statement
name="ELSE"><block type="mqtt_publish" id="smO|L]z*P](,UgueBPs="><field
name="RETAIN">FALSE</field><value name="MESSAGE"><shadow type="text"
id="qzj3LWx^fLmqN@V}LB$+"><field
name="TEXT">message</field></shadow><block type="text"
id="vG}VB{StksB?,KUR2E(L"><field
name="TEXT">close</field></block></value><value name="TOPIC"><shadow
type="text" id="2lfbm=XjVArjH6V?[^_G"><field
name="TEXT">topic</field></shadow><block type="text"
id="C/MtIB$j52-3JYEB=oc?"><field
name="TEXT">shellyplus2pm-30c9228107f8/command/cover:0</field></block></value><value
name="BROKER"><shadow type="oh_thing" id="]|67BV4xtPYO{:s%s0|D"><field
name="thingUid">MyThing</field></shadow><block type="oh_thing"
id="JR5m{ZHga7.KIn!jzok3"><field
name="thingUid">mqtt:broker:f4a9aa0fcc</field></block></value></block></statement></block></xml>
type: application/javascript
script: >
var things = Java.type('org.openhab.core.model.script.actions.Things');
//Rollladen Nordseite runter
if (items.getItem('SZ_Generic_MQTT_Thing_FensterNordseite').state ==
'opening') {
things.getActions('mqtt', 'mqtt:broker:f4a9aa0fcc').publishMQTT('shellyplus2pm-30c9228107f8/command/cover:0', 'stop', 'FALSE' === 'TRUE');
} else if (items.getItem('SZ_Generic_MQTT_Thing_FensterNordseite').state
== 'closing') {
things.getActions('mqtt', 'mqtt:broker:f4a9aa0fcc').publishMQTT('shellyplus2pm-30c9228107f8/command/cover:0', 'stop', 'FALSE' === 'TRUE');
} else {
things.getActions('mqtt', 'mqtt:broker:f4a9aa0fcc').publishMQTT('shellyplus2pm-30c9228107f8/command/cover:0', 'close', 'FALSE' === 'TRUE');
}
type: script.ScriptAction