Page 1 of 1

Problems sending Mail with Value of Sensor

Posted: Tuesday 21 December 2021 11:52
by mastadook
Hi All,

I have again a Question and can´t find my Problem.
I try to send an email if the Temp of the Raspberry Pi is too high
and I like to add the Temperature to the Mail.

This is what I use:

Code: Select all

return {
	on = { 
	    devices = {'Raspi Internal Temperature'},
	    timer = { 'every Minute' } },
        execute = function(domoticz, timer)
        local temp = domoticz.devices('Raspi Internal Temperature').temperature
        print(temp)
        if domoticz.devices('Raspi Internal Temperature').temperature > 50 then
		domoticz.email('Achtung Zentrale läuft heiß', 'Achtung Zentrale läuft heiß, Raspi überhitzt <br> Raspi Temperatur ist ' ..temp '°C', '[email protected]')
      end
end
}
and this is what comes back:

Code: Select all

2021-12-21 11:51:00.566 Error: dzVents: Error: (3.1.7) An error occurred when calling event handler Zentrale Temperatur >70
2021-12-21 11:51:00.566 Error: dzVents: Error: (3.1.7) ...ts/dzVents/generated_scripts/Zentrale Temperatur >70.lua:9: attempt to call a number value (local 'temp')
can anyone help please to get it running?
I think is is something small that I don´t see :)

Re: Problems sending Mail with Value of Sensor

Posted: Tuesday 21 December 2021 12:50
by EddyG
Make the variable a string

Code: Select all

local temp = tostring(domoticz.devices('Raspi Internal Temperature').temperature)

Re: Problems sending Mail with Value of Sensor

Posted: Tuesday 21 December 2021 14:24
by jvdz
You are missing 2 dot after temp:

Code: Select all

'Achtung Zentrale läuft heiß, Raspi überhitzt <br> Raspi Temperatur ist ' ..temp '°C'
should be

Code: Select all

'Achtung Zentrale läuft heiß, Raspi überhitzt <br> Raspi Temperatur ist ' ..temp .. '°C'

Re: Problems sending Mail with Value of Sensor

Posted: Wednesday 22 December 2021 7:21
by mastadook
EddyG wrote: Tuesday 21 December 2021 12:50 Make the variable a string

Code: Select all

local temp = tostring(domoticz.devices('Raspi Internal Temperature').temperature)
yes, this made it a String, but then the Error was ...bla bla attempt to call a string value (local 'temp')

jvdz wrote: Tuesday 21 December 2021 14:24 You are missing 2 dot after temp:

Code: Select all

'Achtung Zentrale läuft heiß, Raspi überhitzt <br> Raspi Temperatur ist ' ..temp '°C'
should be

Code: Select all

'Achtung Zentrale läuft heiß, Raspi überhitzt <br> Raspi Temperatur ist ' ..temp .. '°C'
this was the Trick, I missed the 2 .. Dots after the Variable temp!
Big thanks to both of for you Help.