Little help with script for CO2  [Solved]

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

Moderator: leecollings

Post Reply
domogijs
Posts: 99
Joined: Monday 17 August 2015 23:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Little help with script for CO2

Post by domogijs »

Hi

I am no progammer and can use a little help with this script :)

The idea is that my ikea lamp turns red when co2 is to high.

I have made this script

Code: Select all

return {
    on = { devices = { "CO2" }},
    
    execute = function(domoticz, device)
        Ikea = domoticz.devices(792)
        
        if  (domoticz.devices('CO2').CO2 > 800) then
            
            Ikea.setColorBrightness(100, 100, 5)
        else
            Ikea.switchOff()
        end
    end
}
But i get errors in the log.

Code: Select all


2019-08-18 20:42:35.413 (Netatmo) Air Quality (CO2)
2019-08-18 20:42:35.419 (Netatmo) General/Sound Level (DB)
2019-08-18 20:42:35.773 Status: dzVents: Info: Handling events for: "CO2", value: "617"
2019-08-18 20:42:35.773 Status: dzVents: Info: ------ Start internal script: CO2: Device: "CO2 (Netatmo)", Index: 854
2019-08-18 20:42:35.775 Status: dzVents: Info: ------ Finished CO2
2019-08-18 20:42:35.775 Error: dzVents: Error: (2.4.28) An error occurred when calling event handler CO2
2019-08-18 20:42:35.775 Error: dzVents: Error: (2.4.28) /home/pi/domoticz/scripts/dzVents/generated_scripts/CO2.lua:8: attempt to compare number with nil

What is wrong in the script?

Greets Gijs
Raspberry Pi3, RFlink, PiZigate, Yeelight, klikaanklikuit, Kodi, harmony hub, Zwave, ThermoSmart, XiaomiGateway (Aqara), Google home hub, roomba,
elmortero
Posts: 248
Joined: Sunday 29 November 2015 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9639
Location: Spain
Contact:

Re: Little help with script for CO2  [Solved]

Post by elmortero »

Hi,

Try with (domoticz.devices('CO2').co2 > 800) instead of (domoticz.devices('CO2').CO2 > 800)
It is case sensitive and .co2 should be lower case
domogijs
Posts: 99
Joined: Monday 17 August 2015 23:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Little help with script for CO2

Post by domogijs »

yes! works thanks for taking the effort pointing this out.

Greets Gijs
Raspberry Pi3, RFlink, PiZigate, Yeelight, klikaanklikuit, Kodi, harmony hub, Zwave, ThermoSmart, XiaomiGateway (Aqara), Google home hub, roomba,
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest