Some newbie Questions Topic is solved

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
Raducanu
Posts: 5
Joined: Monday 06 June 2016 9:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Some newbie Questions

Post by Raducanu »

Hello,
at the weekend is started using domoticz to manage and control my automatic garden watering systems.
I have one magnetic valve (will be extended to 3 in the next week). I connected this valve (hunter 24V 1" BSP valve) via a relais to my raspberry GPIO. I can control the valve via a switch. Works perfect.

But now i like to make the solution a bit smarter so i fetching some weather data via WU from a nearby weather station.

I try to achive the following (using blocky and no lua programming if possible)

How to get the highest temperature of the day stored in a virtual dummy device? Blocky won't work.


Thank you!
SweetPants

Re: Some newbie Questions

Post by SweetPants »

Use a uservariable? I dont know if blocky will support that, but lua scripts do

Verstuurd vanaf mijn HTC Desire 610 met Tapatalk
dsummerbell
Posts: 1
Joined: Tuesday 07 June 2016 4:28
Target OS: OS X
Domoticz version:
Contact:

Re: Some newbie Questions

Post by dsummerbell »

That's a good suggestion
Raducanu
Posts: 5
Joined: Monday 06 June 2016 9:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Some newbie Questions

Post by Raducanu »

I figured out that Blockly is not really useful for comparing temeratures.
So i start to dig something together with lua (never did LUA before, the script works, but there are better ways for it)
The script gets the current temerature and compares it with a saved temperature value in a virtual dummy device (Top Temperature). If the current temperature is higher, it replaces the value of the virtual dummy device with the current temperature. At midnight it sets the current temperature to the new Top Temperature.

I was not skilled enough with lua to set the new value of the top temperature device so i used a json call ;)

Image

Image

Code: Select all

-- DayTopTemperature Script by Marcel Mertens
-- Version 0.1
-- This Script stores the highest day temperature in a virtual dummy device. Ad midnight it will set the virtual dummy device to the current Temperatur

commandArray = {}
currenttemp = (tonumber(otherdevices_svalues['Temperatur']))  -- Set Device with current Temperature
toptemp = (tonumber(otherdevices_svalues['Tageshöchsttemperatur'])) -- Set Device with Top Temperature
time = os.date("*t")

print ("---Running Day Top Temperature LUA Script---")
print ("Actual Temperature: " .. currenttemp)
print ("Day Top Temperature: " .. toptemp)

if (time.hour == 0) and (time.min == 00)
then
 commandArray['OpenURL'] = "http://localhost/json.htm?type=command&param=udevice&idx=17&nvalue=0&svalue=" .. currenttemp -- Replace "idx=17" with idx for your Top Tep Temerature Device
 print ("New Day: Setting actual temperature to new Day Top Temperature")
end

if (currenttemp > toptemp) then
commandArray['OpenURL'] = "http://localhost/json.htm?type=command&param=udevice&idx=17&nvalue=0&svalue=" .. currenttemp -- Replace "idx=17" with idx for your Top Tep Temerature Device
print ("Set current temperature to new Day Top Temperature")
else
print ("Actual temperature lower/same than Day Top Temperature")
end
print ("---Ending Day Top Temperature LUA Script---"
return commandArray
SweetPants

Re: Some newbie Questions

Post by SweetPants »

Why use a dummy device to save the highest temp? Unless you want to keep history, a uservariable can be used and is directly accessible
from lua script.

Verstuurd vanaf mijn HTC Desire 610 met Tapatalk
Raducanu
Posts: 5
Joined: Monday 06 June 2016 9:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Some newbie Questions

Post by Raducanu »

Yeah, i could use user var, but it could be interesting to see highest temp of a day...
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest