Get temperature

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
welby
Posts: 36
Joined: Monday 20 November 2017 3:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Australia
Contact:

Get temperature

Post by welby »

I currently have a working script that sends an email to my wife if the temp goes over a certain value and runs every hour. It works fine but i'd like to include the actual temp in the email if possible? This is my current code for testing it but it's not working, i'm sure someone will know where i've gone wrong.

Code: Select all

return {
	on = {
		timer = { 'every minute between 12:00 and 22:00'
		
		}
	},
	execute = function(domoticz, )
		if (domoticz.devices ('Temperature').temperature > 20) then
		    domoticz.email('Hi Prue you may turn the Aircon on because the temp is:' .. 'Temperature'.temperature '',  '*****@gmail.com')
		    end
	        
	 end
}
SweetPants

Re: Get temperature

Post by SweetPants »

Google is your friend, search for LUA string concatenation https://www.lua.org/pil/3.4.html
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Get temperature

Post by waaren »

welby wrote: Wednesday 31 January 2018 7:51 I currently have a working script that sends an email to my wife if the temp goes over a certain value and runs every hour. It works fine but i'd like to include the actual temp in the email if possible? This is my current code for testing it but it's not working, i'm sure someone will know where i've gone wrong.

Code: Select all

return {
	on = {
		timer = { 'every minute between 12:00 and 22:00'
		
		}
	},
	execute = function(domoticz, )
		if (domoticz.devices ('Temperature').temperature > 20) then
		    domoticz.email('Hi Prue you may turn the Aircon on because the temp is:' .. 'Temperature'.temperature '',  '*****@gmail.com')
		    end
	        
	 end
}
There are some other minor syntax errors in your example please find corrected below

Code: Select all

--[[

Email test
    

 ]]
 
return {
	on = {
		timer = { 'every minute between 12:00 and 22:00'
		
		}
	},
	execute = function(domoticz)
		local myTemp = domoticz.devices ('Kantoor').temperature
		if myTemp  < 20 then
			print ("Sending mail")
		    domoticz.email("Temperature alert for Prue", "Hi Prue you may turn the Aircon on because the temp is: " .. tostring(myTemp),  "[email protected]")
		end
	        
	 end
}

Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
welby
Posts: 36
Joined: Monday 20 November 2017 3:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Australia
Contact:

Re: Get temperature

Post by welby »

Awesome waaren it works great thanks alot ;) I've got alot to learn and this has helped me heaps.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests