Menu

LUA Script

Help
hd88
2010-12-24
2012-12-14
  • hd88

    hd88 - 2010-12-24

    Hi,
    the following LUA script works fine, just not in the range of 9 to 3,
    why not? what am I doing wrong?

    Hans

        <object type="9.xxx" id="aussentemp"  >aussentemp</object>
        <object type="1.001" id="pumpe_gaertnerei" >pumpe_gaertnerei</object>

        <rule id="gaerterei">
            <condition type="or">
    <condition type="object" id="aussentemp" trigger="true"/>
    </condition>
    <actionlist type="if-true">
    <action type="script"><![CDATA[
    value = obj("aussentemp")
    if value < ("20") then
      set("pumpe_gaertnerei", 1)
    else
      set("pumpe_gaertnerei", 0)
      end
            ]]>
            </action>
            </actionlist>
        </rule>

     
  • jef2000

    jef2000 - 2010-12-24

    Hi,

    You make a character string comparison: value < ("20")
    So if you temperature is 3, it compares string "3" and "20" character by character. And 3 > 2, so "3" > "20".

    You should try with:
    if tonumber(value) < 20 then

    Regards,

    Jean-François

     
  • hd88

    hd88 - 2010-12-24

    Hi,
    worked, thank you very much, Merry Christmas.
    Hans

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.