LAU to read barometer at x:20

Post Reply
starfish001
Posts: 19
Joined: Monday 29 February 2016 0:54
Target OS: Raspberry Pi
Domoticz version:
Contact:

LAU to read barometer at x:20

Post by starfish001 » Friday 15 September 2017 23:25

i would like to run a time based script to read a barometer from a Esp8266 sensor every hour not sure how to read the sensor

time = os.date("*t")
commandArray = {}
mtAT = devicechanged_svalues['ESPO_bar']

print('####TEST DEBUG: '.. mtAT)

User avatar
jvdz
Posts: 1068
Joined: Tuesday 30 December 2014 20:25
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Westland/Netherlands
Contact:

Re: LAU to read barometer at x:20

Post by jvdz » Saturday 16 September 2017 10:00

What do you mean with: "not sure how to read the sensor"? Is the sensor data already available in Domoticz?
If so then the devicechanged_svalues[] table is wrong as that table doesn't exists (see here). You need to use the otherdevices_svalues[] table.
To execute the logic only one time each hour you could do:

Code: Select all

-- Time to run?
time = os.date("*t")
if (time.min == 0) then
   mtAT = otherdevices_svalues['ESPO_bar'] 
   print('####TEST DEBUG: '.. mtAT)
end
Jos

starfish001
Posts: 19
Joined: Monday 29 February 2016 0:54
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: LAU to read barometer at x:20

Post by starfish001 » Saturday 16 September 2017 20:53

sorry - I have an esp8266 set-up as a sensor sending data into Domoticz every few minutes into a virtual sensor. I wanted to setup alerting. Blocky can do it but it is not very neat so I just wanted to create a timed notification to take the value from the virtual sensor and then create the alert.

Your suggested code snipet fixed my issue perfectly :D

time = os.date("*t")

if time.min == 47 then
espBarReading = otherdevices_svalues['ESPO_bar']
print('####TEST DEBUG Barometer Reading:: '.. espBarReading)
commandArray['SendNotification']='Barometer Reading: '.. espBarReading
end

Post Reply

Who is online

Users browsing this forum: silver323 and 2 guests