Problems sending Mail with Value of Sensor

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

Moderator: leecollings

Post Reply
mastadook
Posts: 58
Joined: Wednesday 18 April 2018 13:03
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: Deutschland
Contact:

Problems sending Mail with Value of Sensor

Post 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 :)
Last edited by mastadook on Wednesday 22 December 2021 9:14, edited 1 time in total.
________________________________________________________________________
global chief of permanent lightning and strike detonator
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Problems sending Mail with Value of Sensor

Post by EddyG »

Make the variable a string

Code: Select all

local temp = tostring(domoticz.devices('Raspi Internal Temperature').temperature)
User avatar
jvdz
Posts: 2446
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Problems sending Mail with Value of Sensor

Post 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'
mastadook
Posts: 58
Joined: Wednesday 18 April 2018 13:03
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: Deutschland
Contact:

Re: Problems sending Mail with Value of Sensor

Post 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.
________________________________________________________________________
global chief of permanent lightning and strike detonator
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest