Blockly Blocks Disappeared

  • Platform information:
    • Hardware: X86
    • OS: Ubuntu 22.04.4
    • Java Runtime Environment: 17.0.11
    • openHAB version:4.2
  • Issue of the topic: Blocks in blockly rules have disappeared

Was running M4 and happened to look into a rule that didn’t run and the blocks in the script were gone. The generated code still exists, and it seems like most rules are running. Looking through all my rules, all but one have the same issues. No blocks, but generated code exists. When I try to add blocks to an existing script, the blocks (on the left) are effectively disabled. Cannot move them.

I upgraded to 4.2 as I was planning a reboot/restart anyway, and the problem persists.

Sounds more like a browser problem. Did you try cleaning the cache or a different browser?

Cleaned cache, same in 3 different browsers. This is what it looks like

or this

image

Making a correction here, several rules are fine. I don’t see a common theme in the rules with missing blocks.

could you paste the code of a rule that doesn’t work?

Been looking through the rules where the blocks have disappeared. Most run, but notably rules with a sendMail action look incomplete.

Here is a rule (blockly generated code) letting me know my wife is getting low on fuel. Some pieces missing in the sendMail (address, subject, etc). So maybe the rule runs, but the parameters are gone.

var Range2;

var Things = Java.type('org.openhab.core.model.script.actions.Things');


if (items.getItem('BMWX3RemainingFuel').numericState < 2) {
  Range2 = items.getItem('BMWX3FuelRange').numericState;
  Range2 = (Range2).toFixed(0);
  if (items.getItem('BMWX3FuelNotificationSent').state != 'ON') {
    Things.getActions('mail', ).sendMail(, , );
  }
} else if (false) {
}

'mail:smtp:6029257d23';

'MyThing';

There was actually more to this rule in the blocks. It checks if a proxy switch (BMWX3FuelNotificationSent) is on, if not it sends the email, then turns on the proxy. When fuel is greater than 2, it checks if proxy is ON, then turns off the proxy if true. All this avoids duplicate emails of course. All that code is missing it seems.

I restored a backup from about a month ago, but the result was the same. I am now back on a current backup from today. Next step will be to rebuild the rule(s). Probably have 30-40 in this condition.

What could be causing this, @stefan.hoehn?

1 Like

Might have to do with Mail Action Library. I cannot recreate the rules because the library is empty. Tried removing and adding the library back, but no change.

1 Like

I meant paste the code from the code tab of the rule. Then we can see if the code for the blocks is complete and if blocks get rendered.

@florian-h05 / @stefan.hoehn if this was caused by missing blocks / extensions, perhaps we could detect this and pop up a warning? Also somehow prevent the blocks from being wiped out accidentally, yet still allowing people to clear it out and start over if they wanted to.

I have the bad feeling that it might be caused by Blocks from the LIbrary which are not under our control. Finding the root cause is probably becoming complicated.

Rules are not shown when blocks are broken.
I would recommend opening the code of the rule which contains the XML of the blocks. Try to find the blocks in the XML that are coming from a library and remove them and see if the rule works now. I know this is tedious but probably the only way to find out.

@JimT Until now I have not yet found out how this could be prevented as this is rendered internally by Blockly (I had these problems myself when I debugged breaking changes or errors in my code).

1 Like

Got it. This actually looks more complete.

configuration: {}
triggers:
  - id: "1"
    configuration:
      itemName: BMWX3RemainingFuel
    type: core.ItemStateChangeTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      blockSource: <xml
        xmlns="https://developers.google.com/blockly/xml"><variables><variable
        id="H]*y_up0]vKJvNljx^j1">Range</variable></variables><block
        type="controls_if" id="y](E5vvjz!|0-f45-1Ak" x="220" y="38"><mutation
        elseif="1"></mutation><value name="IF0"><block type="logic_compare"
        id="M-lR44+H-3lKtz#9OJ)f"><field name="OP">LT</field><value
        name="A"><block type="oh_getitem_attribute"
        id="]8`Z?{v){BWj-`,PCPMF"><mutation
        attributeName="NumericState"></mutation><field
        name="attributeName">NumericState</field><value name="item"><shadow
        type="oh_getitem" id="`MK~#[,WRaVEK48_zd)`"><value
        name="itemName"><shadow type="oh_item"
        id="74x^NF$njOos#,C9~fpf"><mutation itemName="MyItem"
        itemLabel="MyItem"></mutation><field
        name="itemName">MyItem</field></shadow></value></shadow><block
        type="oh_getitem" id="p8rKflerD]_9($wlN]a,"><value
        name="itemName"><shadow type="oh_item"
        id="%*0J?E#U]#n-H6=fWUq+"><mutation itemName="MyItem"
        itemLabel="MyItem"></mutation><field
        name="itemName">MyItem</field></shadow><block type="oh_item"
        id="Q=rMg).1cD6IK[SffAl2"><mutation itemName="BMWX3RemainingFuel"
        itemLabel="BMW X3 Remaining Fuel"></mutation><field
        name="itemName">BMWX3RemainingFuel</field></block></value></block></value></block></value><value
        name="B"><block type="math_number" id="rSg@Gh?=RbC%%n+8Zp3K"><field
        name="NUM">2</field></block></value></block></value><statement
        name="DO0"><block type="variables_set" id="]hg0E}_XD,fgN9=:mmxh"><field
        name="VAR" id="H]*y_up0]vKJvNljx^j1">Range</field><value
        name="VALUE"><block type="oh_getitem_attribute"
        id="|e0d(d=#1QFrvpM]4j#g"><mutation
        attributeName="NumericState"></mutation><field
        name="attributeName">NumericState</field><value name="item"><shadow
        type="oh_getitem" id="49xLVrULQWgLB[leL4*m"><value
        name="itemName"><shadow type="oh_item"
        id="=|#vn+%(j$A$^q+`snNQ"><mutation itemName="MyItem"
        itemLabel="MyItem"></mutation><field
        name="itemName">MyItem</field></shadow></value></shadow><block
        type="oh_getitem" id="bo)jiyy~CHE-;`K3}*)Y"><value
        name="itemName"><shadow type="oh_item"
        id="vuG3(.=)R2VNxJet@@=#"><mutation itemName="MyItem"
        itemLabel="MyItem"></mutation><field
        name="itemName">MyItem</field></shadow><block type="oh_item"
        id="x:pj0j0lMk:t9/hC~[7S"><mutation itemName="BMWX3FuelRange"
        itemLabel="BMW X3 Fuel Range"></mutation><field
        name="itemName">BMWX3FuelRange</field></block></value></block></value></block></value><next><block
        type="variables_set" id="zdxy%|m~!Mmw^dY3EG|0"><field name="VAR"
        id="H]*y_up0]vKJvNljx^j1">Range</field><value name="VALUE"><block
        type="math_round" id="m#W{fo1X-m,WITKn;$Bh" inline="true"><field
        name="op">toFixed</field><value name="NUM"><shadow type="math_number"
        id="s*J:Sk_TZGh,M}u$obCQ"><field name="NUM">3.1</field></shadow><block
        type="variables_get" id="(,%|H(I.9SFU9ZMNF~kW"><field name="VAR"
        id="H]*y_up0]vKJvNljx^j1">Range</field></block></value><value
        name="DECIMALS"><shadow type="math_number"
        id="6K,W9vN`H=C1Z^Os97XM"><field name="NUM">2</field></shadow><block
        type="math_number" id="?i;qWcBW2XMNjp9i!pSS"><field
        name="NUM">0</field></block></value></block></value><next><block
        type="controls_if" id="edy:Yz)SVncE|(prjqJC"><value name="IF0"><block
        type="logic_compare" id="3b4touo/e(TFIdk(6By3"><field
        name="OP">NEQ</field><value name="A"><block type="oh_getitem_state"
        id="kL=T{DVo(2jmBkONC/jP"><value name="itemName"><shadow type="oh_item"
        id="mN+{Kkiw:KW+v7OBWW5h"><mutation itemName="MyItem"
        itemLabel="MyItem"></mutation><field
        name="itemName">MyItem</field></shadow><block type="oh_item"
        id="3*]qHA77Hv+3kxNY.Eju"><mutation itemName="BMWX3FuelNotificationSent"
        itemLabel="BMW X3 Fuel Notification Sent (Proxy)"></mutation><field
        name="itemName">BMWX3FuelNotificationSent</field></block></value></block></value><value
        name="B"><block type="text" id="?USEv(5Je$_ZUF4hJ7ws"><field
        name="TEXT">ON</field></block></value></block></value><statement
        name="DO0"><block type="mherwege:blocky:mail_send_mail"
        id="f,ZvJKrFO:q^q^vaoGT$"><field name="TYPE"></field><value
        name="SERVER"><shadow type="oh_thing" id="Ywny.fei*]7YCPQuB*U9"><field
        name="thingUid">MyThing</field></shadow><block type="oh_thing"
        id="z!G?GX$#7`8SY,s.W65i"><field
        name="thingUid">mail:smtp:6029257d23</field></block></value><value
        name="RECIPIENTS"><shadow type="text" id="y)6mC$.d)EKvN%*SFx::"><field
        name="TEXT">recipients</field></shadow><block type="text"
        id=".7gXK1M6a202mzKDBw7("><field
        name="TEXT">xxxxxxxxx@gmail.com</field></block></value><value
        name="SUBJECT"><shadow type="text" id="xPI]DPW6`J@okzn^g#OL"><field
        name="TEXT">subject</field></shadow><block type="text"
        id="rvJt$fHWKr?@iZ+`#3Lb"><field name="TEXT">BMW X3 Fuel
        Low</field></block></value><value name="CONTENT"><shadow type="text"
        id="U]Q:PzWK1K:Cb%rzkZ%%"><field
        name="TEXT">message</field></shadow><block type="text_join"
        id="$|cn[N44I_XV=#~Dg_$]"><mutation items="3"></mutation><value
        name="ADD0"><block type="text" id="E[P+^#w7R$Bxwc*~6?{T"><field
        name="TEXT">BMW has only </field></block></value><value
        name="ADD1"><block type="variables_get" id="P54vAp^796n(.1`6~RHJ"><field
        name="VAR" id="H]*y_up0]vKJvNljx^j1">Range</field></block></value><value
        name="ADD2"><block type="text" id="]_|!i+B1G;i257L8manr"><field
        name="TEXT"> miles of gas
        left.</field></block></value></block></value><next><block
        type="oh_event" id="/eAV4_btYczY*^(^-A=^"><field
        name="eventType">sendCommand</field><value name="value"><shadow
        type="text" id=".:6`F;gTs#0[_ATC7T70"><field
        name="TEXT">value</field></shadow><block type="text"
        id=")Ji^S}2yU/l^7AEW^5y^"><field
        name="TEXT">ON</field></block></value><value name="itemName"><shadow
        type="oh_item" id=",$7*cZ=aRZ4/u}x6G07p"><mutation itemName="MyItem"
        itemLabel="MyItem"></mutation><field
        name="itemName">MyItem</field></shadow><block type="oh_item"
        id="*2nwcLh|~xt$}+x24ywV"><mutation itemName="BMWX3FuelNotificationSent"
        itemLabel="BMW X3 Fuel Notification Sent (Proxy)"></mutation><field
        name="itemName">BMWX3FuelNotificationSent</field></block></value></block></next></block></statement></block></next></block></next></block></statement><value
        name="IF1"><block type="logic_compare" id="wPnl,c%rzSY8__Ujm!Pr"><field
        name="OP">GTE</field><value name="A"><block type="oh_getitem_attribute"
        id="J2$cfsOa@)Aq}/[Zl|8#"><mutation
        attributeName="NumericState"></mutation><field
        name="attributeName">NumericState</field><value name="item"><shadow
        type="oh_getitem" id=")@.]3%Q0JaGWj1cOd.u,"><value
        name="itemName"><shadow type="oh_item"
        id=".kkhU|8Kz#4ZQ#q8R)3I"><mutation itemName="MyItem"
        itemLabel="MyItem"></mutation><field
        name="itemName">MyItem</field></shadow></value></shadow><block
        type="oh_getitem" id="slEqB6`Kidv1oI/;C2^c"><value
        name="itemName"><shadow type="oh_item"
        id="LGqY-44J!y8ij#`3lJe]"><mutation itemName="MyItem"
        itemLabel="MyItem"></mutation><field
        name="itemName">MyItem</field></shadow><block type="oh_item"
        id="S+G~Du;}rIFyRJtX^N@:"><mutation itemName="BMWX3RemainingFuel"
        itemLabel="BMW X3 Remaining Fuel"></mutation><field
        name="itemName">BMWX3RemainingFuel</field></block></value></block></value></block></value><value
        name="B"><block type="math_number" id="z1#{4Qm2LPh)h0!rCb@e"><field
        name="NUM">2</field></block></value></block></value><statement
        name="DO1"><block type="controls_if" id="MuMUyL#dlsb@NTpvbh?*"><value
        name="IF0"><block type="logic_compare" id="e#oL+QM~pp?7aO|}:-9Y"><field
        name="OP">NEQ</field><value name="A"><block type="oh_getitem_state"
        id=",yhY,t^c%)DzYt;o^H~8"><value name="itemName"><shadow type="oh_item"
        id="K#pC#W+yoov-~2gHP7Kw"><mutation itemName="MyItem"
        itemLabel="MyItem"></mutation><field
        name="itemName">MyItem</field></shadow><block type="oh_item"
        id="7VTJx^5vBY{[cuv+p{-1"><mutation itemName="BMWX3FuelNotificationSent"
        itemLabel="BMW X3 Fuel Notification Sent (Proxy)"></mutation><field
        name="itemName">BMWX3FuelNotificationSent</field></block></value></block></value><value
        name="B"><block type="text" id="Q,=)fdJj!;$qqv5}tH]y"><field
        name="TEXT">OFF</field></block></value></block></value><statement
        name="DO0"><block type="oh_event" id="I~i{OCh/7!a5}n*~gh8l"><field
        name="eventType">sendCommand</field><value name="value"><shadow
        type="text" id="Vg}dV;tVG#A+n5Z_z5=7"><field
        name="TEXT">value</field></shadow><block type="text"
        id=":bzi$qkX%O5otL^RBiAN"><field
        name="TEXT">OFF</field></block></value><value name="itemName"><shadow
        type="oh_item" id="x~vIBdcJ%5`K*xTZK4$_"><mutation itemName="MyItem"
        itemLabel="MyItem"></mutation><field
        name="itemName">MyItem</field></shadow><block type="oh_item"
        id="gy]B11mfjSitFq4YU9t0"><mutation itemName="BMWX3FuelNotificationSent"
        itemLabel="BMW X3 Fuel Notification Sent (Proxy)"></mutation><field
        name="itemName">BMWX3FuelNotificationSent</field></block></value></block></statement></block></statement></block></xml>
      type: application/javascript
      script: >
        var Range2;


        var Things = Java.type('org.openhab.core.model.script.actions.Things');



        if (items.getItem('BMWX3RemainingFuel').numericState < 2) {
          Range2 = items.getItem('BMWX3FuelRange').numericState;
          Range2 = (Range2).toFixed(0);
          if (items.getItem('BMWX3FuelNotificationSent').state != 'ON') {
            Things.getActions('mail', 'mail:smtp:6029257d23').sendMail('xxxxxx@gmail.com', 'BMW X3 Fuel Low', ['BMW has only ',Range2,' miles of gas left.'].join(''));
            items.getItem('BMWX3FuelNotificationSent').sendCommand('ON');
          }
        } else if (items.getItem('BMWX3RemainingFuel').numericState >= 2) {
          if (items.getItem('BMWX3FuelNotificationSent').state != 'OFF') {
            items.getItem('BMWX3FuelNotificationSent').sendCommand('OFF');
          }
        }
    type: script.ScriptAction

I just did a clean install on another system, and the Mail Actions Block Library is still not working.

1 Like

Yes, that looks complete. I don’t find anything wrong, but as Stefan commented it might be hard to find.
I pasted the code into a fresh rule but it didn’t get rendered.
I never experienced a problem like that during upgrades although I stepped through all the milestones till the 4.2 release.
Sorry: I’m out of ideas.

Thanks for the effort.

I have done the same. Not really sure which Milestone things changed, since all the rules seem to run except for ones using sendMail. I still don’t understand why the Mail Actions Library on a fresh system doesn’t work. If someone else is having a similar issue, I would be grateful for some insights.

Been a good run of upgrades for me since 2.4, but I guess it was my time to get bit…

no offense :wink:: Did you check if the mail binding is installed? The blocky library needs it.

image

In would ask the author of the mail blockly library to look into it. It might have to do with the blockly upgrade that was done by Jim that required changes on our internal implementation of all blocks. If that was the case here it could affect many more libraries as well

I will look at it, but won’t be able to do so for a few weeks. What kind of changes where required with the upgrade?

Here is the PR that did the upgrade

I can also vouch for this, it’s broken all our Blockly mail notifications due to Mail Actions not showing anything, if you switch to code and switch back it shows a portion of the original blocks, but mail actions just shows thing which is unselectable