Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Expire option for setState-block only works with directly entered values, not with variables or calculations #1780

Open
3 tasks done
Hoedi1030 opened this issue Dec 21, 2024 · 0 comments

Comments

@Hoedi1030
Copy link

I'm sure that

  • This issue is still present in the current beta version of this adapter
  • There is no other (open) issue with the same topic (use the search!)
  • This issue is not described in the adapter documentation / FAQ (read the docs!)

Script type

Blockly

The problem

When using a setState-block in combination with a computed (e.g. per math-block or per variable) value for the expires in (sec) option, it gets ignored.

Example 1 with calculated value (does not work)

See the following example with a calculated value for the expiry time:
image

Below is the resulting auto-generated JS-Code from Blockly and the corresponding Blockly-XML.

Blockly auto-generated JS-Code and Blockly-XML

setStateDelayed('0_userdata.0.TEST01', { val: true, ack: false }, parseInt(((0) || '').toString(), 10), false);
<xml xmlns="https://developers.google.com/blockly/xml">
  <block type="control_ex" id="P*nZcIMY^X!9h,hLe!r," x="213" y="263">
    <field name="TYPE">false</field>
    <field name="CLEAR_RUNNING">FALSE</field>
    <value name="OID">
      <shadow type="field_oid" id="W]Kn]0hc]$=w{/+.GiC_">
        <field name="oid">0_userdata.0.TEST01</field>
      </shadow>
    </value>
    <value name="VALUE">
      <shadow type="logic_boolean" id="eDGtKi$zaXj-y68hy,JK">
        <field name="BOOL">TRUE</field>
      </shadow>
    </value>
    <value name="DELAY_MS">
      <shadow type="math_number" id="Hm|-y!COl7v[Y%ef1wY7">
        <field name="NUM">0</field>
      </shadow>
    </value>
    <value name="EXPIRE">
      <shadow type="math_number" id="/V81.XxA~I?j!oQ-JpN1">
        <field name="NUM">2</field>
      </shadow>
      <block type="math_arithmetic" id="2TjbTjx3(EPLc*HL/Bsa">
        <field name="OP">ADD</field>
        <value name="A">
          <shadow type="math_number" id="tlVAMf^S+z--nS7y2mv.">
            <field name="NUM">1</field>
          </shadow>
        </value>
        <value name="B">
          <shadow type="math_number" id="F_z9ZwK8~+,XHTR%DXJ`">
            <field name="NUM">1</field>
          </shadow>
        </value>
      </block>
    </value>
  </block>
</xml>


Example 2 with directly entered value (works as expected)

On the other hand, if i directly provide a fixed value as seen in the following example, everything is working as expected:
image

Consider the resulting JS-Code below, where the given value of 2 is accounted for by "expire: 2".
I think that this is the part that is missing in the above example 1 and therefore it behaves abnormally...

Blockly auto-generated JS-Code and Blockly-XML

setStateDelayed('0_userdata.0.TEST01', { val: true, ack: false, expire: 2 }, parseInt(((0) || '').toString(), 10), false);
<xml xmlns="https://developers.google.com/blockly/xml">
  <block type="control_ex" id="P*nZcIMY^X!9h,hLe!r," x="213" y="263">
    <field name="TYPE">false</field>
    <field name="CLEAR_RUNNING">FALSE</field>
    <value name="OID">
      <shadow type="field_oid" id="W]Kn]0hc]$=w{/+.GiC_">
        <field name="oid">0_userdata.0.TEST01</field>
      </shadow>
    </value>
    <value name="VALUE">
      <shadow type="logic_boolean" id="eDGtKi$zaXj-y68hy,JK">
        <field name="BOOL">TRUE</field>
      </shadow>
    </value>
    <value name="DELAY_MS">
      <shadow type="math_number" id="Hm|-y!COl7v[Y%ef1wY7">
        <field name="NUM">0</field>
      </shadow>
    </value>
    <value name="EXPIRE">
      <shadow type="math_number" id="/V81.XxA~I?j!oQ-JpN1">
        <field name="NUM">2</field>
      </shadow>
    </value>
  </block>
</xml>

TL;DR: When using the expiry-feature of the setState-Block, only directly entered values are accounted for; It does not work with variables or calculations.

iobroker.current.log (in debug mode!)

No response

Version of nodejs

18.20.5

Version of ioBroker js-controller

7.0.3

Version of adapter

8.8.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants