ioBroker / ioBroker.javascript

Script engine for JavaScript and Blockly
MIT License
325 stars 120 forks source link

[Bug]: Obsolete schedule warning #1574

Closed ScumbagSteve closed 4 months ago

ScumbagSteve commented 4 months ago

I'm sure that

Script type

Blockly Schedule warning

The problem

When using the "Zeitplan aus Zeit-Zustand" trigger, I get a schedule warning in the log: Test-Skript: More than 100 schedules registered. Check your script!

I was able to recreate this with a very basic script: grafik

It seems like each trigger is treated as a "new" one, and therefore sooner or later a warning is issued. This could be "works as designed", however I would assume that this warning does not consider "overwritten" triggers. Is there maybe an issue with releasing scheduled triggers in the background, and it's therefore taken into account?

Attached to blockly code to import:

<xml xmlns="https://developers.google.com/blockly/xml">
  <block type="update" id="#i!Lku!S`y:~nSYhL8C@" x="138" y="88">
    <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
    <field name="OID">0_userdata.0.Test-DP</field>
    <field name="WITH_DELAY">FALSE</field>
    <value name="VALUE">
      <block type="convert_from_date" id="gxSIKT(*!RwEwk.!+Dwq">
        <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation>
        <field name="OPTION">hh:mm:ss</field>
        <value name="VALUE">
          <block type="time_calculation" id="L#;Af+J}WzY8Y2*r%HAn">
            <field name="OPERATION">+</field>
            <field name="UNIT">sec</field>
            <value name="DATE_TIME">
              <shadow type="time_get" id="ltIFxIXE[lBTJm[Z[VvI">
                <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation>
                <field name="OPTION">object</field>
              </shadow>
            </value>
            <value name="VALUE">
              <shadow type="math_number" id="TU~[#4LU0+n![rXcCrK0">
                <field name="NUM">1</field>
              </shadow>
            </value>
          </block>
        </value>
      </block>
    </value>
    <next>
      <block type="schedule_by_id" id="3jnZoX7+Z-irkfU8_,g:">
        <field name="OID">0_userdata.0.Test-DP</field>
        <field name="ACK_CONDITION"></field>
        <statement name="STATEMENT">
          <block type="update" id="J#E[e~@9,J,[Bs]cz-f5">
            <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
            <field name="OID">0_userdata.0.Test-DP</field>
            <field name="WITH_DELAY">FALSE</field>
            <value name="VALUE">
              <block type="convert_from_date" id="^!zfR#@|x?f-M=rj:p|[">
                <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation>
                <field name="OPTION">hh:mm:ss</field>
                <value name="VALUE">
                  <block type="time_calculation" id="PdM5tx8J_E[HHEA|D#rb">
                    <field name="OPERATION">+</field>
                    <field name="UNIT">sec</field>
                    <value name="DATE_TIME">
                      <shadow type="time_get" id="VWV5J0%D!9Q)qFX2)8J5">
                        <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation>
                        <field name="OPTION">object</field>
                      </shadow>
                    </value>
                    <value name="VALUE">
                      <shadow type="math_number" id="80=*0baJet9)[6@m=V]i">
                        <field name="NUM">1</field>
                      </shadow>
                    </value>
                  </block>
                </value>
              </block>
            </value>
          </block>
        </statement>
      </block>
    </next>
  </block>
</xml>

iobroker.current.log (in debug mode!)

No response

Version of nodejs

v18.19.1

Version of ioBroker js-controller

5.0.19

Version of adapter

8.1.1

klein0r commented 4 months ago

Thanks, could reproduce the issue:

createState('test_scheduleById', '00:00', async () => {
    scheduleById('test_scheduleById', () => {
        // ...
    });
    await setStateAsync('test_scheduleById', '10:11', true);
    await setStateAsync('test_scheduleById', '10:12', true);
    await setStateAsync('test_scheduleById', '10:13', true);
    await setStateAsync('test_scheduleById', '10:14', true);

    console.error(__engine.__schedules);
    console.error(JSON.stringify(getSchedules(false)));
});

returns 5 instead of 1. Just counting is wrong, schedule works like expected