-
Notifications
You must be signed in to change notification settings - Fork 25
Trash Calendar Visualization
Hosenroller edited this page Feb 1, 2021
·
3 revisions
Visualization for the trashschedule adapter, which is a precondition for this view to work.
- Name of the device:
Müllabfuhr|{trashschedule.0.next.typesText}
- Device type:
Wert
- State:
javascript.0.trashschedule.nextDateCustom
- as type datapoint (will be generated by a blockly script - see below) - HTML:
javascript.0.trashschedule.typesHtml
- as type datapoint (also generated by the blockly script)
- Icon on/off:
./images/icons/blank.png|./../iqontrol.meta/userimages/usericons/{trashschedule.0.next.typesText}.png
Upload the icons (see below).
- Condition for active tile: To get the tile highlighted if it is the current day (or the day before), set it to
State ID => trashschedule.0.next.daysLeft
andcondition = 1
Create a new blockly script and import the code (the name doesn't matter):
<xml xmlns="https://developers.google.com/blockly/xml">
<variables>
<variable id="D*]zCynPnJHien4@k(`_">html</variable>
<variable id="yWH*YxoaAz;uaUBPJi}B">json</variable>
<variable id="wR*)5=uku_vjQiIm0jgI">trashEntry</variable>
</variables>
<block type="comment" id="*Jt^l(VTUWvM(cb8jS$~" x="-88" y="87">
<field name="COMMENT">Initialize</field>
<next>
<block type="create" id="OvlHapT24x;#rP1KUckD">
<field name="NAME">trashschedule.typesHtml</field>
<value name="VALUE">
<block type="text" id="TUCG?C6PFLlSM@~A0bIY">
<field name="TEXT">-</field>
</block>
</value>
<value name="COMMON">
<block type="text" id="]O}T~!quZn6?P.$HCKG@">
<field name="TEXT">{"name": "Types as HTML", "read": true, "write": false, "unit": ""}</field>
</block>
</value>
<next>
<block type="create" id="PWnlQ:Ocfk(5]6#[o6EI">
<field name="NAME">trashschedule.nextDateCustom</field>
<value name="VALUE">
<block type="text" id="|^03X|C?%(9$U-U0uBvq">
<field name="TEXT">-</field>
</block>
</value>
<value name="COMMON">
<block type="text" id=")q;}Oh;|2`t$cJqZ@),t">
<field name="TEXT">{"name": "Next date custom format", "read": true, "write": false, "unit": "", "type": "string"}</field>
</block>
</value>
<next>
<block type="comment" id="M@{5e1$j(s.w72vq)Z)$">
<field name="COMMENT">Create Trigger</field>
<next>
<block type="on_ext" id=";DuJah]lOOMR}K9?/Wix">
<mutation xmlns="http://www.w3.org/1999/xhtml" items="1"></mutation>
<field name="CONDITION">ne</field>
<field name="ACK_CONDITION"></field>
<value name="OID0">
<shadow type="field_oid" id="o#/t1*tsd.NX~,o/XNLZ">
<field name="oid">trashschedule.0.next.types</field>
</shadow>
</value>
<statement name="STATEMENT">
<block type="procedures_callnoreturn" id="Rn^+BYO|nTp}bbY5`@K_">
<mutation name="setTrashscheduleHtml"></mutation>
<next>
<block type="procedures_callnoreturn" id="[Z!SEjGJ2Vz_yDOTR})d">
<mutation name="setNextPrintValue"></mutation>
</block>
</next>
</block>
</statement>
<next>
<block type="comment" id="I2]ZY+!ly3JtDCDhXE(J">
<field name="COMMENT">Run once in the beginning</field>
<next>
<block type="procedures_callnoreturn" id="eznx$`C~BZZHWH@_G_n{">
<mutation name="setTrashscheduleHtml"></mutation>
<next>
<block type="procedures_callnoreturn" id=";.nr%DJ;]qjpDh;GLpK%">
<mutation name="setNextPrintValue"></mutation>
<next>
<block type="comment" id="ioC{%6=LTv9vXe5i:My*">
<field name="COMMENT">Don't need a cronjob, trashschedule triggers it</field>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
<block type="procedures_defnoreturn" id="?3VSJ8nM+!-+eiwRSq7q" x="637" y="88">
<field name="NAME">setNextPrintValue</field>
<comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
<statement name="STACK">
<block type="debug" id="lh^hR8ox1fdrkm(q3e]e">
<field name="Severity">debug</field>
<value name="TEXT">
<shadow type="text" id="jK3p%98VT2=XOcEI5~D}">
<field name="TEXT">Start setNextPrintValue</field>
</shadow>
</value>
<next>
<block type="comment" id="l5`GR$-NXQ9b!3F^,[6w">
<field name="COMMENT">Write result</field>
<next>
<block type="control_ex" id="}nddUO#Lfr1}NWmt(V)[">
<field name="TYPE">true</field>
<field name="CLEAR_RUNNING">FALSE</field>
<value name="OID">
<shadow type="field_oid" id=")QvZ/XGQBW!#xb0IgF-v">
<field name="oid">trashschedule.0.next.date</field>
</shadow>
<block type="field_oid" id="@N5-FU,S=E|!dOCJ+CeF">
<field name="oid">javascript.0.trashschedule.nextDateCustom</field>
</block>
</value>
<value name="VALUE">
<shadow type="logic_boolean" id="rj2U!vAolh^!o2xt]%~r">
<field name="BOOL">TRUE</field>
</shadow>
<block type="convert_from_date" id="]|yK:S%%@/01|Bm:32h(">
<mutation xmlns="http://www.w3.org/1999/xhtml" format="true" language="false"></mutation>
<field name="OPTION">custom</field>
<field name="FORMAT">WW, TT.MM.</field>
<value name="VALUE">
<block type="get_value" id="BAx8^q+6THoM;hamN}~H">
<field name="ATTR">val</field>
<field name="OID">trashschedule.0.next.date</field>
</block>
</value>
</block>
</value>
<value name="DELAY_MS">
<shadow type="math_number" id="4qKtH]MlVSBXWsG@d(o+">
<field name="NUM">0</field>
</shadow>
</value>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" id="V6XSW.d7qJ{MHS6OvHE^" x="637" y="387">
<field name="NAME">setTrashscheduleHtml</field>
<comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
<statement name="STACK">
<block type="debug" id="$nT-zd0TdnYAcF6y;|0v">
<field name="Severity">debug</field>
<value name="TEXT">
<shadow type="text" id="@Lm$mq#w~V#VS,`s.ZXM">
<field name="TEXT">Start setTrashscheduleHtml</field>
</shadow>
</value>
<next>
<block type="comment" id="!@PS`IB7Ds-1qt3i,.2L">
<field name="COMMENT">Initialize vars</field>
<next>
<block type="variables_set" id="(P+l0$ANC8J2)CM%yh2$">
<field name="VAR" id="D*]zCynPnJHien4@k(`_">html</field>
<value name="VALUE">
<block type="text" id="jAM3{IGvC=QUQ1oMy,H]">
<field name="TEXT"><ul></field>
</block>
</value>
<next>
<block type="variables_set" id="s,Y}4lOj5.@6YTXf}*c:">
<field name="VAR" id="yWH*YxoaAz;uaUBPJi}B">json</field>
<value name="VALUE">
<block type="get_value" id="7UqiHQ;dE$[Xl0pJwvTK">
<field name="ATTR">val</field>
<field name="OID">trashschedule.0.type.json</field>
</block>
</value>
<next>
<block type="debug" id="pE}C@MS~W/aHmQ~a9g)$">
<field name="Severity">debug</field>
<value name="TEXT">
<shadow type="text" id="~~Ct!-t%CWV(RZ+[q*J1">
<field name="TEXT">Starte setzeTrashscheduleHtml</field>
</shadow>
<block type="convert_json2object" id="fyG,)*Bc8KpUYZXir{oS">
<value name="VALUE">
<block type="variables_get" id="WOX3{gH_tUYvm/XwqZO:">
<field name="VAR" id="yWH*YxoaAz;uaUBPJi}B">json</field>
</block>
</value>
</block>
</value>
<next>
<block type="comment" id="%zuicH_:=4[iOneYPUvY">
<field name="COMMENT">Loop through all trash events</field>
<next>
<block type="controls_forEach" id="$0a4mt`9H[kr.o{sH`4z">
<field name="VAR" id="wR*)5=uku_vjQiIm0jgI">trashEntry</field>
<value name="LIST">
<block type="convert_json2object" id="Gs5UXIA]pxuq6]m?!gM?">
<value name="VALUE">
<block type="variables_get" id="uW8L!$cyji#z,ElON~7g">
<field name="VAR" id="yWH*YxoaAz;uaUBPJi}B">json</field>
</block>
</value>
</block>
</value>
<statement name="DO">
<block type="variables_set" id="`/}1Sl8QBzIVs5wy:MYW">
<field name="VAR" id="D*]zCynPnJHien4@k(`_">html</field>
<value name="VALUE">
<block type="text_join" id="kdx_7hTTgQEZ=APV|ZK[">
<mutation items="10"></mutation>
<value name="ADD0">
<block type="variables_get" id="!r[C=Sb@=g=P=@@nm5%c">
<field name="VAR" id="D*]zCynPnJHien4@k(`_">html</field>
</block>
</value>
<value name="ADD1">
<block type="text" id="c,}CQOvYsVyNj0Req/$c">
<field name="TEXT"><li style="color: </field>
</block>
</value>
<value name="ADD2">
<block type="get_attr" id="$fho^Zc[HsR{;?e0N!_l">
<value name="PATH">
<shadow type="text" id="a7~mFhfytO$!wq0{$ap1">
<field name="TEXT">_color</field>
</shadow>
</value>
<value name="OBJECT">
<block type="variables_get" id="#IEmA!(q7*;Ef@{PS]y$">
<field name="VAR" id="wR*)5=uku_vjQiIm0jgI">trashEntry</field>
</block>
</value>
</block>
</value>
<value name="ADD3">
<block type="text" id="]F^39LEn]S/tsv/:14,[">
<field name="TEXT">"></field>
</block>
</value>
<value name="ADD4">
<block type="get_attr" id="(rr%9O11~,-|kPBItX^A">
<value name="PATH">
<shadow type="text" id="RR[C-Scv|Q[Vwh)V(?Wi">
<field name="TEXT">name</field>
</shadow>
</value>
<value name="OBJECT">
<block type="variables_get" id="$V(h9.h-yu!wK[-}v+mq">
<field name="VAR" id="wR*)5=uku_vjQiIm0jgI">trashEntry</field>
</block>
</value>
</block>
</value>
<value name="ADD5">
<block type="text" id="$]@vOxr+Vmd0%}dhpbT;">
<field name="TEXT">: </field>
</block>
</value>
<value name="ADD6">
<block type="convert_from_date" id="^XTU27Sg=Z$*@ML^n*|K">
<mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="true"></mutation>
<field name="OPTION">wdt</field>
<field name="LANGUAGE">de</field>
<value name="VALUE">
<block type="get_attr" id="pgea]xY{yQbf7iOZba]J">
<value name="PATH">
<shadow type="text" id="P0b4q8}EcRNv~g)]$Ex0">
<field name="TEXT">nextDate</field>
</shadow>
</value>
<value name="OBJECT">
<block type="variables_get" id=",93=rk^vd~2}/(lNJSo[">
<field name="VAR" id="wR*)5=uku_vjQiIm0jgI">trashEntry</field>
</block>
</value>
</block>
</value>
</block>
</value>
<value name="ADD7">
<block type="text" id="zqpk6D`e3UQuuvuy3iEt">
<field name="TEXT"> in </field>
</block>
</value>
<value name="ADD8">
<block type="get_attr" id="Wo$5R|yh~(moH(!LJ~ig">
<value name="PATH">
<shadow type="text" id="P$/4n1AlQ}HSx#8C;Me]">
<field name="TEXT">daysLeft</field>
</shadow>
</value>
<value name="OBJECT">
<block type="variables_get" id=":Up!*)%}3@4KZwSF}8$g">
<field name="VAR" id="wR*)5=uku_vjQiIm0jgI">trashEntry</field>
</block>
</value>
</block>
</value>
<value name="ADD9">
<block type="text" id="_#S5+g!RA#HY*%XP108f">
<field name="TEXT"> Tage</li></field>
</block>
</value>
</block>
</value>
</block>
</statement>
<next>
<block type="variables_set" id="9WQ80UW,COFv+D$)[mmx">
<field name="VAR" id="D*]zCynPnJHien4@k(`_">html</field>
<value name="VALUE">
<block type="text_join" id="E@?:4CmE2Vf`BZ~82//W">
<mutation items="2"></mutation>
<value name="ADD0">
<block type="variables_get" id="9z8h_5Zn|9pRBrn[p#@n">
<field name="VAR" id="D*]zCynPnJHien4@k(`_">html</field>
</block>
</value>
<value name="ADD1">
<block type="text" id="m*1yu^)7Pf^{9QlP3*RU">
<field name="TEXT"></ul></field>
</block>
</value>
</block>
</value>
<next>
<block type="debug" id="BN!#Xw]%keVb{:lO[Xth">
<field name="Severity">debug</field>
<value name="TEXT">
<shadow type="text" id="M{Fd#=8jL0860F=wU8~5">
<field name="TEXT">test</field>
</shadow>
<block type="variables_get" id="J$kZ9sT8545)%{#xm{G`">
<field name="VAR" id="D*]zCynPnJHien4@k(`_">html</field>
</block>
</value>
<next>
<block type="comment" id="~@%*0[4pAleCR}|SPeK/">
<field name="COMMENT">Write result</field>
<next>
<block type="control_ex" id="fTz+yCo]=zzK~t~en.k@">
<field name="TYPE">true</field>
<field name="CLEAR_RUNNING">FALSE</field>
<value name="OID">
<shadow type="field_oid" id="2!qMViY~_o(rld0#1?.G">
<field name="oid">javascript.0.trashschedule.typesHtml</field>
</shadow>
</value>
<value name="VALUE">
<shadow type="logic_boolean" id="y1?Vt0,[4kyY6i+{JUO$">
<field name="BOOL">TRUE</field>
</shadow>
<block type="variables_get" id="6bm:FOU/bv!h|FyKE[r^">
<field name="VAR" id="D*]zCynPnJHien4@k(`_">html</field>
</block>
</value>
<value name="DELAY_MS">
<shadow type="math_number" id="Vg|kT:4M:+~EJG$SS0ma">
<field name="NUM">0</field>
</shadow>
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
</xml>
The blockly script uses the colors for the html description as defined in the trashschedule, therefore, don't forget to set the right colors there, see example:
Upload the attached icons in iQontrol under Images/Widgets
in /usericons
. Please make sure to name the icons according to the values from "typesText" from the trashschedule adapter. When using Umlauts, this might be a little tricky, but should work.
Should look like this: