NEWS
ShellyLED mit Json per Blockly Steuern / Dimmen
-
Hi Zs,
ich habe ein Problem und hoffe Ihr könnt mir helfen.
Ich habe nach und nach meine Sonoffs und nun auch meine Shelly auf MQTT umgestellt.mein bisheriges Blockly hatte die Objekte gesteurt und lief super.
Es werden 3 LED-Stränge zu unterschiedlichen Zeiten erst eingeschaltet, die Brightness auf 1 gestellt und dann schritweise um 1 erhöht bis Sie komplett Leuchten.
<xml xmlns="http://www.w3.org/1999/xhtml"> <variables> <variable type="undefined" id="Intervall2">Intervall2</variable> <variable type="undefined" id="Intervall1">Intervall1</variable> <variable type="undefined" id="Intervall3">Intervall3</variable> <variable type="undefined" id="Intervall4">Intervall4</variable> <variable type="undefined" id="Intervall5">Intervall5</variable> <variable type="undefined" id="Intervall6">Intervall6</variable> </variables> <block type="schedule" id="dFsy~.H~Vz|c#~[1Ar~K" x="-2213" y="-1037"> <field name="SCHEDULE">{"time":{"exactTime":true,"start":"06:30"},"period":{"days":1}}</field> <statement name="STATEMENT"> <block type="control" id="|pg{48[uMZ~d+[^$NcBL"> <mutation delay_input="false"></mutation> <field name="OID">mqtt.0.shellies.shellyrgbw2-661CD1.white.0.command</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="text" id="J4,*0WHeUUda%uR2Dfuj"> <field name="TEXT">on</field> </block> </value> <next> <block type="control" id="DPu9:ZErz7*@$JPn7-ID"> <mutation delay_input="false"></mutation> <field name="OID">mqtt.0.shellies.shellyrgbw2-661CD1.white.0.command</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="text" id="(P=(x*4YrT[?o6*VK+Ph"> <field name="TEXT">1</field> </block> </value> <next> <block type="comment" id="8Jp9u+k~BeHuSCV4^]#F"> <field name="COMMENT">6 Sekunden Intervall bei 100 als Max Wert bedeutet dimmen in 10 Minuten</field> <next> <block type="comment" id="G@S2)ldsSk2/:c!fwX=q"> <field name="COMMENT">500ms sind ein guter Wert für zügiges hoch/runter Dimmen</field> <next> <block type="timeouts_setinterval" id="||nx?p9s`g:b^G:%^K-/"> <field name="NAME">Intervall1</field> <field name="INTERVAL">6</field> <field name="UNIT">sec</field> <statement name="STATEMENT"> <block type="controls_if" id="`r3J6B98q3n[-V+W_448"> <mutation else="1"></mutation> <value name="IF0"> <block type="logic_compare" id="{|%r#gvfL@x[s$R^t7GV"> <field name="OP">LT</field> <value name="A"> <block type="get_value" id="gHu;/QEk*b*}Ezfp6Uxq"> <field name="ATTR">val</field> <field name="OID">mqtt.0.shellies.shellyrgbw2-661CD1.white.1.status</field> </block> </value> <value name="B"> <block type="math_number" id="**1x+)/[5JrT7jWWCSpB"> <field name="NUM">100</field> </block> </value> </block> </value> <statement name="DO0"> <block type="control" id="n#:Hx6?::L@%3Ka#)2n5"> <mutation delay_input="false"></mutation> <field name="OID">shelly.0.SHRGBW2#661CD1#1.white1.brightness</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="math_arithmetic" id="ltsp%YwgN/pQu7W#w|k["> <field name="OP">ADD</field> <value name="A"> <shadow type="math_number" id="tSa(@Me46JE#QlwQL3v;"> <field name="NUM">1</field> </shadow> <block type="get_value" id="4z.^!486bxG;38W=a/T0"> <field name="ATTR">val</field> <field name="OID">shelly.0.SHRGBW2#661CD1#1.white1.brightness</field> </block> </value> <value name="B"> <shadow type="math_number" id="/5@~j7QF*]EHD{[479Nm"> <field name="NUM">1</field> </shadow> </value> </block> </value> </block> </statement> <statement name="ELSE"> <block type="timeouts_clearinterval" id="hRo@cfm~{Ycti.EM+aBW"> <field name="NAME">Intervall1</field> </block> </statement> </block> </statement> </block> </next> </block> </next> </block> </next> </block> </next> </block> </statement> <next> <block type="schedule" id="eZr:0^RW:Zn7!DPz+8:P"> <field name="SCHEDULE">{"time":{"exactTime":true,"start":"07:00"},"period":{"days":1}}</field> <statement name="STATEMENT"> <block type="control" id="r@FXtSGbBnOTR`V1ZOe("> <mutation delay_input="false"></mutation> <field name="OID">shelly.0.SHRGBW2#661CD1#1.white2.Switch</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="logic_boolean" id="BfY1_d!OE,hWK^%nwU|8"> <field name="BOOL">TRUE</field> </block> </value> <next> <block type="control" id="nmEW$Ntf[mbtb}5TMFuq"> <mutation delay_input="false"></mutation> <field name="OID">shelly.0.SHRGBW2#661CD1#1.white2.brightness</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="math_number" id="ee2N/{`R!xN-I0#3OudZ"> <field name="NUM">1</field> </block> </value> <next> <block type="timeouts_setinterval" id="S[Mt::{C/-4YR).94/ic"> <field name="NAME">Intervall2</field> <field name="INTERVAL">6</field> <field name="UNIT">sec</field> <statement name="STATEMENT"> <block type="controls_if" id="P67+U/[Aoc/@c`oJj/2p"> <mutation else="1"></mutation> <value name="IF0"> <block type="logic_compare" id="(,^?Rai;+BEiv=B~hqAw"> <field name="OP">LT</field> <value name="A"> <block type="get_value" id="M9#mD.GL%nNmCvUnR9fL"> <field name="ATTR">val</field> <field name="OID">mqtt.0.shellies.shellyrgbw2-661CD1.white.1.Blau_Brightness</field> </block> </value> <value name="B"> <block type="math_number" id="m?7X*(moy(coREN^HwZ8"> <field name="NUM">100</field> </block> </value> </block> </value> <statement name="DO0"> <block type="control" id="t7v5VU`]nqP1lR6H,CzK"> <mutation delay_input="false"></mutation> <field name="OID">mqtt.0.shellies.shellyrgbw2-661CD1.white.1.Blau_Brightness</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="math_arithmetic" id="vb98+Enqpe|gK!6F95Yc"> <field name="OP">ADD</field> <value name="A"> <shadow type="math_number" id="tSa(@Me46JE#QlwQL3v;"> <field name="NUM">1</field> </shadow> <block type="get_value" id="vPj;Rl`+d@^X75gXW/U@"> <field name="ATTR">val</field> <field name="OID">mqtt.0.shellies.shellyrgbw2-661CD1.white.1.Blau_Brightness</field> </block> </value> <value name="B"> <shadow type="math_number" id="s=LY_Q-UrPGG/kh*$a{J"> <field name="NUM">1</field> </shadow> </value> </block> </value> </block> </statement> <statement name="ELSE"> <block type="timeouts_clearinterval" id="P*r,XDkv|5T5d13Y{`-`"> <field name="NAME">Intervall2</field> </block> </statement> </block> </statement> </block> </next> </block> </next> </block> </statement> <next> <block type="schedule" id="ME~y0:KCaq+;cwiC][JG"> <field name="SCHEDULE">{"time":{"exactTime":true,"start":"07:40"},"period":{"days":1}}</field> <statement name="STATEMENT"> <block type="control" id="!C(cJS$!zs(CM7.xu~Ra"> <mutation delay_input="false"></mutation> <field name="OID">shelly.0.SHRGBW2#661CD1#1.white0.Switch</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="logic_boolean" id="w.Q5x?`%34|ZOJ_^@:K%"> <field name="BOOL">TRUE</field> </block> </value> <next> <block type="control" id="f^1@e6$a-J#KN=1.ip.e"> <mutation delay_input="false"></mutation> <field name="OID">shelly.0.SHRGBW2#661CD1#1.white0.brightness</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="math_number" id="K{4}W^-4yTXzi2=R@ZE["> <field name="NUM">1</field> </block> </value> <next> <block type="timeouts_setinterval" id="xbE2m+~lpb$4E?s$SLtD"> <field name="NAME">Intervall3</field> <field name="INTERVAL">12</field> <field name="UNIT">sec</field> <statement name="STATEMENT"> <block type="controls_if" id="YZw~Y-=%:Qoe|EZ@U2tB"> <mutation else="1"></mutation> <value name="IF0"> <block type="logic_compare" id="bGKIi)g|#9|.a|@Z1[S%"> <field name="OP">LT</field> <value name="A"> <block type="get_value" id="qwkxMys=Xp^3uzCe![[["> <field name="ATTR">val</field> <field name="OID">shelly.0.SHRGBW2#661CD1#1.white0.brightness</field> </block> </value> <value name="B"> <block type="math_number" id=";sr@urwI{T55?A5@%Oiv"> <field name="NUM">100</field> </block> </value> </block> </value> <statement name="DO0"> <block type="control" id=":n9?3N26J9WB$_wl{nQf"> <mutation delay_input="false"></mutation> <field name="OID">shelly.0.SHRGBW2#661CD1#1.white0.brightness</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="math_arithmetic" id="O~v.cx{d(7E8!H=xE~L:"> <field name="OP">ADD</field> <value name="A"> <shadow type="math_number" id="tSa(@Me46JE#QlwQL3v;"> <field name="NUM">1</field> </shadow> <block type="get_value" id="BoQ;6TM|`=:0E{p/Jq;C"> <field name="ATTR">val</field> <field name="OID">shelly.0.SHRGBW2#661CD1#1.white0.brightness</field> </block> </value> <value name="B"> <shadow type="math_number" id="CKc%hoSh!$in_3x:B`9r"> <field name="NUM">1</field> </shadow> </value> </block> </value> </block> </statement> <statement name="ELSE"> <block type="timeouts_clearinterval" id="}#q?lx?}U_2N%/RCh[)D"> <field name="NAME">Intervall4</field> </block> </statement> </block> </statement> </block> </next> </block> </next> </block> </statement> <next> <block type="schedule" id="j9)c@b,+kx]mo2:7_!MF"> <field name="SCHEDULE">{"time":{"exactTime":true,"start":"19:15"},"period":{"days":1}}</field> <statement name="STATEMENT"> <block type="control" id="ScZ*4DDK5Czp(@7v#]`E"> <mutation delay_input="false"></mutation> <field name="OID">shelly.0.SHRGBW2#661CD1#1.white0.brightness</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="math_number" id="_q2HADF%6hru9zfMc,E7"> <field name="NUM">100</field> </block> </value> <next> <block type="timeouts_setinterval" id="9$[07FN{U/J`k;RPF{$z"> <field name="NAME">Intervall4</field> <field name="INTERVAL">12</field> <field name="UNIT">sec</field> <statement name="STATEMENT"> <block type="controls_if" id="8_bL=eN3_FFKWwd}=EqK"> <mutation else="1"></mutation> <value name="IF0"> <block type="logic_compare" id="y1lGg2a]xcS$7$@-_F{2"> <field name="OP">GT</field> <value name="A"> <block type="get_value" id="FA,pyxfxF;pr32IHx7E]"> <field name="ATTR">val</field> <field name="OID">shelly.0.SHRGBW2#661CD1#1.white0.brightness</field> </block> </value> <value name="B"> <block type="math_number" id="Md4_{-0W`w2l~@6fBL;c"> <field name="NUM">0</field> </block> </value> </block> </value> <statement name="DO0"> <block type="control" id="c1Wz[9h}.VTc7VwKq$(g"> <mutation delay_input="false"></mutation> <field name="OID">shelly.0.SHRGBW2#661CD1#1.white0.brightness</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="math_arithmetic" id="^A#kr%{vqm0*dvyvg01]"> <field name="OP">MINUS</field> <value name="A"> <shadow type="math_number" id="tSa(@Me46JE#QlwQL3v;"> <field name="NUM">1</field> </shadow> <block type="get_value" id="6%4Ok~HC]Z](L(R;btWo"> <field name="ATTR">val</field> <field name="OID">shelly.0.SHRGBW2#661CD1#1.white0.brightness</field> </block> </value> <value name="B"> <shadow type="math_number" id="`#Zh~mY@9HV$#+/}]8ep"> <field name="NUM">1</field> </shadow> </value> </block> </value> </block> </statement> <statement name="ELSE"> <block type="timeouts_clearinterval" id="d(Xw,32AQY(Lo@PTb/O^"> <field name="NAME">Intervall4</field> </block> </statement> </block> </statement> </block> </next> </block> </statement> <next> <block type="schedule" id="=~:HF8C:eGk?4=OylE)c"> <field name="SCHEDULE">{"time":{"exactTime":true,"start":"20:15"},"period":{"days":1}}</field> <statement name="STATEMENT"> <block type="control" id="qH_8P:xfQ6w]u~)}xGg_"> <mutation delay_input="false"></mutation> <field name="OID">shelly.0.SHRGBW2#661CD1#1.white2.brightness</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="math_number" id="o6O09:@BAFGZ8T41(nnT"> <field name="NUM">100</field> </block> </value> <next> <block type="timeouts_setinterval" id="w;eM:6b}Yok6SZS+hNIY"> <field name="NAME">Intervall5</field> <field name="INTERVAL">10</field> <field name="UNIT">sec</field> <statement name="STATEMENT"> <block type="controls_if" id="E9qK$hsKay?*8R_#Q$e2"> <mutation else="1"></mutation> <value name="IF0"> <block type="logic_compare" id="ed%Zq1i;9Yi`Ob-LK0V;"> <field name="OP">GT</field> <value name="A"> <block type="get_value" id="0lN[GGOU,(KZkHtZC2wV"> <field name="ATTR">val</field> <field name="OID">shelly.0.SHRGBW2#661CD1#1.white2.brightness</field> </block> </value> <value name="B"> <block type="math_number" id="kdSF=N%Oba8($[nn/,i2"> <field name="NUM">0</field> </block> </value> </block> </value> <statement name="DO0"> <block type="control" id="XQJoZ;f04}X[C,?HAE#?"> <mutation delay_input="false"></mutation> <field name="OID">shelly.0.SHRGBW2#661CD1#1.white2.brightness</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="math_arithmetic" id="K2j-}@3hC=/5!$n,@Y67"> <field name="OP">MINUS</field> <value name="A"> <shadow type="math_number" id="tSa(@Me46JE#QlwQL3v;"> <field name="NUM">1</field> </shadow> <block type="get_value" id="9fImv#m(Lb=[5dX`oiKJ"> <field name="ATTR">val</field> <field name="OID">shelly.0.SHRGBW2#661CD1#1.white2.brightness</field> </block> </value> <value name="B"> <shadow type="math_number" id="W@Cs-Bh[N!/qxnbm$S|i"> <field name="NUM">1</field> </shadow> </value> </block> </value> </block> </statement> <statement name="ELSE"> <block type="timeouts_clearinterval" id="Jg6,M^vP^t[kbP8Uo0:p"> <field name="NAME">Intervall5</field> </block> </statement> </block> </statement> </block> </next> </block> </statement> <next> <block type="schedule" id="]$xU$W5=AECTa_p:7s9W"> <field name="SCHEDULE">{"time":{"exactTime":true,"start":"21:00"},"period":{"days":1}}</field> <statement name="STATEMENT"> <block type="control" id="njAlWi|m@0IYDkQbC%J."> <mutation delay_input="false"></mutation> <field name="OID">shelly.0.SHRGBW2#661CD1#1.white1.brightness</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="math_number" id="#MwO-_2-PS6~X5x3@Ql-"> <field name="NUM">100</field> </block> </value> <next> <block type="timeouts_setinterval" id="1bZjJHW!+173vrO{$M6L"> <field name="NAME">Intervall6</field> <field name="INTERVAL">8</field> <field name="UNIT">sec</field> <statement name="STATEMENT"> <block type="controls_if" id="``L}W:~+KvN8dFqU_]0*"> <mutation else="1"></mutation> <value name="IF0"> <block type="logic_compare" id="rpM8_F1AHMN2M#qkm@!^"> <field name="OP">GT</field> <value name="A"> <block type="get_value" id="dqNNInr%fy)D4#xbG,=w"> <field name="ATTR">val</field> <field name="OID">shelly.0.SHRGBW2#661CD1#1.white1.brightness</field> </block> </value> <value name="B"> <block type="math_number" id="6!1[k^qexun$dstj[*r!"> <field name="NUM">0</field> </block> </value> </block> </value> <statement name="DO0"> <block type="control" id="#i+OjuXW~}^dmR~-CVAJ"> <mutation delay_input="false"></mutation> <field name="OID">shelly.0.SHRGBW2#661CD1#1.white1.brightness</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="math_arithmetic" id="[6QYJ$T6#{MT!,phdnko"> <field name="OP">MINUS</field> <value name="A"> <shadow type="math_number" id="tSa(@Me46JE#QlwQL3v;"> <field name="NUM">1</field> </shadow> <block type="get_value" id="SOq6d`HLz)MP3jpt.Rt+"> <field name="ATTR">val</field> <field name="OID">shelly.0.SHRGBW2#661CD1#1.white1.brightness</field> </block> </value> <value name="B"> <shadow type="math_number" id="c?w^OYdW8sV/vSQ{eFyN"> <field name="NUM">1</field> </shadow> </value> </block> </value> </block> </statement> <statement name="ELSE"> <block type="timeouts_clearinterval" id="};D6b=0c5P*_-]J8xv-F"> <field name="NAME">Intervall6</field> </block> </statement> </block> </statement> </block> </next> </block> </statement> <next> <block type="schedule" id="NP|}@;USn!yFW~cLwby@"> <field name="SCHEDULE">{"time":{"exactTime":true,"start":"21:35"},"period":{"days":1}}</field> <statement name="STATEMENT"> <block type="control" id="fswGL0zAF]#9|:M1fUl}"> <mutation delay_input="false"></mutation> <field name="OID">shelly.0.SHRGBW2#661CD1#1.white1.Switch</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="logic_boolean" id="=b[;rqb1eH4})d.pg0/#"> <field name="BOOL">FALSE</field> </block> </value> <next> <block type="control" id="eM)p@Q$THzP~R7nm)]iT"> <mutation delay_input="false"></mutation> <field name="OID">shelly.0.SHRGBW2#661CD1#1.white2.Switch</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="logic_boolean" id="b6FP0ud*1@KtydAd0rlR"> <field name="BOOL">FALSE</field> </block> </value> <next> <block type="control" id="?v$cv?i`1)o[kS.ij7=I"> <mutation delay_input="false"></mutation> <field name="OID">shelly.0.SHRGBW2#661CD1#1.white0.Switch</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="logic_boolean" id="%.YEC#MSh[oK|FRaph78"> <field name="BOOL">FALSE</field> </block> </value> <next> <block type="timeouts_clearinterval" id="QX#gmcm(dNphdPBVz.j*"> <field name="NAME">Intervall1</field> <next> <block type="timeouts_clearinterval" id="UI0|)nyjq(hTtOUnyD$4"> <field name="NAME">Intervall2</field> <next> <block type="timeouts_clearinterval" id="%-e/cS[`ffB5v^PdJdmJ"> <field name="NAME">Intervall3</field> <next> <block type="timeouts_clearinterval" id=":xRCK7^]HxZO[RR?}eoS"> <field name="NAME">Intervall4</field> <next> <block type="timeouts_clearinterval" id="1|@@h49_fbgkzBLV/,,n"> <field name="NAME">Intervall5</field> <next> <block type="timeouts_clearinterval" id="XR!xAA,X9u;XKIokxfw!"> <field name="NAME">Intervall6</field> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </statement> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </xml>
Ich habe per Node-Red ein Objekt für den Zustand erzeugen können:
Der Shelly erwartet folgendes:
mosquitto_sub -t 'shellies/shellyrgbw2-11ABD9/color/0/status' shellies/shellyrgbw2-11ABD9/color/0/status { "ison":true, "red":34, "green":34, "blue":34, "white":34, "gain":5, "effect":0, "power":0.00, "overpower":false } White-mode MQTT This mode allows for independent control of the 4 output channels with an identical set of MQTT topics. Channels are indexed 0 to 3. Command topics shellies/shellyrgbw2-<deviceid>/white/<n>/command accepts on and off payloads shellies/shellyrgbw2-<deviceid>/white/<n>/set accepts a JSON payload with two possible keys: brightness sets output level, 0 to 100; turn can be on or off, acts just like publishing to .../command mosquitto_pub -t shellies/shellyrgbw2-11ABD9/white/2/set \ -m '{"brightness":70}'
Im Skript habe ich Strings ausgeben lassen, es müssten aber JSON sein
Was ich nicht schaffe ist die Rückgabe aus einem Objekt als JSON an den Shelly.
Weder in Blockly noch in Node-Red.Beide Varianten wären kein Problem da ich die States in node red erzeugen und im Skript nutzen könnte oder das Skript als node red nachbauen könnte.
Kann mir jemand mit den Brightness- und On states helfen? Wie gesagt, egal ob als Blockly oder Node-Red flow. Dann könnte ich über die States wieder das originale Skript nutzen.