My stupid Owl script

Moderator: leecollings

Post Reply
Aadr
Posts: 19
Joined: Tuesday 09 June 2015 21:26
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: The Nederlands
Contact:

My stupid Owl script

Post by Aadr »

I am not new to Domoticz, but I am a slow learner, I guess.
I am trying to make a script to control the public lights at the soccerclub. I have an Owl device watching the energy comsuption, and when it exceeds the limit of 15 kW the public lights should turn off.
But after searching the forums and trying lots of possibilities, my scripts will not work. And I cannot figure out why not.

Is the someone out there, who will help me with the script I made so far.

The print-command is execuded good, but the switch 'Multi' will not act.

Code: Select all

--script Veldverlichting aan dan straatverlichting uit


commandArray = {}
  c = 15000 --Watt treshold energy usage
  s = otherdevices_svalues['Veld/straatverlichting'] -- gets value from owl energy device monitoring veldverlichting
 

function five()   -- function to get only usage from string
   local f = (string.sub(s, 1, 5))
   return f 
   end


k = five(f)

   if (devicechanged['Veld/straatverlichting'] and tonumber(k) > c)  then -- triggers compare two numbers
       commandArray['Multi 1'] = 'off'  -- switches straatverlichting off 
              print("straatverlichting uit")  -- prints status
   end
   
return commandArray
many thanks in advance.
User avatar
bizziebis
Posts: 182
Joined: Saturday 19 October 2013 14:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8805
Location: The Netherlands
Contact:

Re: My stupid Owl script

Post by bizziebis »

If the print works, then so would your script. The only thing I can see is you set the Multi switch to 'off' instead of 'Off'. But I don't know if its case sensitive.
jmleglise
Posts: 192
Joined: Monday 12 January 2015 23:27
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: FRANCE
Contact:

Re: My stupid Owl script

Post by jmleglise »

hi,
Something's curious with your function. You have no parameters.
should be :
function five(s) -- function to get only usage from string
return f
end

try this :

Code: Select all

    --script Veldverlichting aan dan straatverlichting uit

    commandArray = {}
    c = 15000 --Watt treshold energy usage
    s = otherdevices_svalues['Veld/straatverlichting'] -- gets value from owl energy device monitoring veldverlichting

    k = string.sub(s, 1, 5)
    if (devicechanged['Veld/straatverlichting'] and tonumber(k) > c)  then -- triggers compare two numbers
           commandArray['Multi 1'] = 'Off'  -- switches straatverlichting off
           print("straatverlichting uit")  -- prints status
    end

-- and for debugging : 
print('K:'..k)
print('s:'..s)
print('C:'..c)
print(otherdevices_svalues['Multi 1'])
print(otherdevices['Multi 1'])

    return commandArray
Last edited by jmleglise on Saturday 06 February 2016 15:28, edited 1 time in total.
My script : https://github.com/jmleglise
RFXTRX433E: Blind Somfy RTS, Portal Somfy Evolvia, chacon IO, Oregon, PIR sensor PT2262
My Last project : Location de vacances a Ouistreham vue mer
KMTronic USB relay
Chinese Z-WAVE: Neo CoolCam
Aadr
Posts: 19
Joined: Tuesday 09 June 2015 21:26
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: The Nederlands
Contact:

Re: My stupid Owl script

Post by Aadr »

Joepie!!!! :D :D :D

Thank you very much, Bizziebis, the command is indeed case sensitive.

jmleglise; thanks for your reply, I will try your improvements as well. I think I can learn from them.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest