Irrigation garden with buienradar Topic is solved

Moderator: leecollings

dheuts
Posts: 65
Joined: Monday 25 March 2019 15:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Brunssum, Netherlands
Contact:

Re: Irrigation garden with buienradar

Post by dheuts »

waaren wrote: Monday 24 August 2020 10:40
dheuts wrote: Monday 24 August 2020 9:34 Can you please help me how to make a script in dzVents so this works?
I already edited your script so it works for one of the sensors for the water. How to make this script working for all 4 plants and also the plant food sensors?
Happy to help but need some additional information.

Names, types and subtypes of all involved sensors
Per plant the water- and foodlimits to decide when notification is required.
That's a quick response! Thanks a lot!
If it's possible to make it for 2 sensors, I think I can do the rest myself?
Please check the sensor types, subtypes and names in the attachment below.

I would like notifications when next limits will be reached (for example the Bananenboom = Banana Tree)

Voeding <350 AND Vochtigheid <40: Bananenboom heeft voeding nodig
Vochtigheid <20: Bananenboom heeft water nodig

Thanks a lot!
Attachments
Sensors.png
Sensors.png (40.76 KiB) Viewed 1609 times
Raspberry Pi 4 With Domoticz - RFXCom - Tuya Wifi LED lights - Chuango Alarm - Zwave+ - Zigbee2MQTT - Anna Thermostat - Broadlink IR, P1 - Eufy Robo Vacuum - Worx Robo Mower
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Irrigation garden with buienradar

Post by waaren »

dheuts wrote: Monday 24 August 2020 22:06 If it's possible to make it for 2 sensors, I think I can do the rest myself?
Can you try this?

Code: Select all

return
{
    on =
    {
        timer =
        {
            'at 09:39',
         },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG, -- set to domoticz.LOG_ERROR when OK
        marker = 'Plant Meldingen',
    },

    execute = function(dz)

        local function checkPlants(t)
            for idx, r in ipairs(t) do
                local deviceMoisture = tonumber(dz.devices(r[1] .. ' Vochtigheid').moisture)
                local deviceConductivity = tonumber(dz.devices(r[1] .. ' Voeding').rawData[1])
                dz.log(r[1] .. ', moisture = '.. deviceMoisture .. ' ; conductivity = ' ..deviceConductivity, dz.LOG_DEBUG)
                if deviceMoisture < r[4] then
                    dz.notify('Plamts', r[1] .. ' needs water',dz.PRIORITY_NORMAL)
                elseif deviceMoisture < r[3] and deviceConductivity <  r[2] then
                    dz.notify('Plants', r[1] .. ' needs nutrient',dz.PRIORITY_NORMAL)
                end
            end
        end

        checkPlants
        ( {
            {'Zolder Bananenboom', 350, 40, 20 }, -- device name prefix, combined fences, H20 fence
            {'Voordeur olijf', 300, 45, 18 },
         -- {'next plant',200,33,44},   
        } )

    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dheuts
Posts: 65
Joined: Monday 25 March 2019 15:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Brunssum, Netherlands
Contact:

Re: Irrigation garden with buienradar

Post by dheuts »

Thanks a lot! I see this error:

Code: Select all

2020-08-25 14:13:00.333 Status: dzVents: Info: Plant Meldingen: ------ Start internal script: Plant meldingen 2:, trigger: "at 14:13"
2020-08-25 14:13:00.361 Status: dzVents: Debug: Plant Meldingen: Processing device-adapter for Zolder Bananenboom Vochtigheid: Soil Moisture device
2020-08-25 14:13:00.363 Status: dzVents: Debug: Plant Meldingen: Processing device-adapter for Zolder Bananenboom Voeding: Custom sensor device adapter
2020-08-25 14:13:00.363 Status: dzVents: Info: Plant Meldingen: ------ Finished Plant meldingen 2
2020-08-25 14:13:00.363 Error: dzVents: Error: (3.0.2) Plant Meldingen: An error occurred when calling event handler Plant meldingen 2
2020-08-25 14:13:00.363 Error: dzVents: Error: (3.0.2) Plant Meldingen: .../scripts/dzVents/generated_scripts/Plant meldingen 2.lua:23: attempt to concatenate a nil value
Raspberry Pi 4 With Domoticz - RFXCom - Tuya Wifi LED lights - Chuango Alarm - Zwave+ - Zigbee2MQTT - Anna Thermostat - Broadlink IR, P1 - Eufy Robo Vacuum - Worx Robo Mower
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Irrigation garden with buienradar

Post by waaren »

dheuts wrote: Tuesday 25 August 2020 14:14

Code: Select all

2020-08-25 14:13:00.363 Error: dzVents: Error: (3.0.2) Plant Meldingen: .../scripts/dzVents/generated_scripts/Plant meldingen 2.lua:23: attempt to concatenate a nil value
sensorValue is not implemented yet in version 3.0.2
can you change line 22 from

Code: Select all

                local deviceConductivity = dz.devices(r[1] .. ' Voeding').sensorValue
to

Code: Select all

                local deviceConductivity = dz.devices(r[1] .. ' Voeding').rawData[1]
and try again
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dheuts
Posts: 65
Joined: Monday 25 March 2019 15:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Brunssum, Netherlands
Contact:

Re: Irrigation garden with buienradar

Post by dheuts »

Thanks, the notifications are working now.
But I get a notification for Bananenboom and Olijf, while I only expect it for Olijf, because Bananenboom conductivity is >350.
In the log I see:

Code: Select all

2020-08-25 15:57:00.474 Status: dzVents: Info: Plant Meldingen: ------ Start internal script: Plant meldingen 2:, trigger: "at 15:57"
2020-08-25 15:57:00.501 Status: dzVents: Debug: Plant Meldingen: Processing device-adapter for Zolder Bananenboom Vochtigheid: Soil Moisture device
2020-08-25 15:57:00.503 Status: dzVents: Debug: Plant Meldingen: Processing device-adapter for Zolder Bananenboom Voeding: Custom sensor device adapter
2020-08-25 15:57:00.503 Status: dzVents: Debug: Plant Meldingen: Zolder Bananenboom, moisture = 46 ; conductivity = 385
2020-08-25 15:57:00.505 Status: dzVents: Debug: Plant Meldingen: Processing device-adapter for Voordeur Olijf Vochtigheid: Soil Moisture device
2020-08-25 15:57:00.506 Status: dzVents: Debug: Plant Meldingen: Processing device-adapter for Voordeur Olijf Voeding: Custom sensor device adapter
2020-08-25 15:57:00.507 Status: dzVents: Debug: Plant Meldingen: Voordeur Olijf, moisture = 45 ; conductivity = 297
2020-08-25 15:57:00.508 Status: dzVents: Debug: Plant Meldingen: Processing device-adapter for Kantoor Plant Vochtigheid: Soil Moisture device
2020-08-25 15:57:00.510 Status: dzVents: Debug: Plant Meldingen: Processing device-adapter for Kantoor Plant Voeding: Custom sensor device adapter
2020-08-25 15:57:00.510 Status: dzVents: Debug: Plant Meldingen: Kantoor Plant, moisture = 53 ; conductivity = 480
2020-08-25 15:57:00.512 Status: dzVents: Debug: Plant Meldingen: Processing device-adapter for Woonkamer Yucca Vochtigheid: Soil Moisture device
2020-08-25 15:57:00.514 Status: dzVents: Debug: Plant Meldingen: Processing device-adapter for Woonkamer Yucca Voeding: Custom sensor device adapter
2020-08-25 15:57:00.514 Status: dzVents: Debug: Plant Meldingen: Woonkamer Yucca, moisture = 78 ; conductivity = 453
2020-08-25 15:57:00.514 Status: dzVents: Info: Plant Meldingen: ------ Finished Plant meldingen 2
Raspberry Pi 4 With Domoticz - RFXCom - Tuya Wifi LED lights - Chuango Alarm - Zwave+ - Zigbee2MQTT - Anna Thermostat - Broadlink IR, P1 - Eufy Robo Vacuum - Worx Robo Mower
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Irrigation garden with buienradar

Post by waaren »

dheuts wrote: Tuesday 25 August 2020 16:04 But I get a notification for Bananenboom and Olijf, while I only expect it for Olijf, because Bananenboom conductivity is >350.
What if you change

Code: Select all

elseif deviceMoisture < r[3] and deviceMoisture < r[2] then
to

Code: Select all

elseif deviceMoisture < r[3] and deviceConductivity < r[2] then
?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dheuts
Posts: 65
Joined: Monday 25 March 2019 15:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Brunssum, Netherlands
Contact:

Re: Irrigation garden with buienradar

Post by dheuts »

Thanks a lot for your fast reply. Looks like the solution....
But I still get an error:

Code: Select all

2020-08-25 17:02:00.464 Status: dzVents: Info: Plant Meldingen: ------ Start internal script: Plant meldingen 2:, trigger: "at 17:02"
2020-08-25 17:02:00.494 Status: dzVents: Debug: Plant Meldingen: Processing device-adapter for Zolder Bananenboom Vochtigheid: Soil Moisture device
2020-08-25 17:02:00.497 Status: dzVents: Debug: Plant Meldingen: Processing device-adapter for Zolder Bananenboom Voeding: Custom sensor device adapter
2020-08-25 17:02:00.497 Status: dzVents: Debug: Plant Meldingen: Zolder Bananenboom, moisture = 46 ; conductivity = 375
2020-08-25 17:02:00.497 Status: dzVents: Info: Plant Meldingen: ------ Finished Plant meldingen 2
2020-08-25 17:02:00.497 Error: dzVents: Error: (3.0.2) Plant Meldingen: An error occurred when calling event handler Plant meldingen 2
2020-08-25 17:02:00.497 Error: dzVents: Error: (3.0.2) Plant Meldingen: .../scripts/dzVents/generated_scripts/Plant meldingen 2.lua:26: attempt to compare string with number
Raspberry Pi 4 With Domoticz - RFXCom - Tuya Wifi LED lights - Chuango Alarm - Zwave+ - Zigbee2MQTT - Anna Thermostat - Broadlink IR, P1 - Eufy Robo Vacuum - Worx Robo Mower
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Irrigation garden with buienradar

Post by waaren »

dheuts wrote: Tuesday 25 August 2020 17:04 2020-08-25 17:02:00.497 Error: dzVents: Error: (3.0.2) Plant Meldingen: .../scripts/dzVents/generated_scripts/Plant meldingen 2.lua:26: attempt to compare string with number
If you see this error message it can almost always be solved by explicit convert the string to a number with the tonumber function. Also here by
changing

Code: Select all

                local deviceMoisture = dz.devices(r[1] .. ' Vochtigheid').moisture
                local deviceConductivity = dz.devices(r[1] .. ' Voeding').rawData[1]
to

Code: Select all

                 local deviceMoisture = tonumber(dz.devices(r[1] .. ' Vochtigheid').moisture)
                local deviceConductivity = tonumber(dz.devices(r[1] .. ' Voeding').rawData[1]) 
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dheuts
Posts: 65
Joined: Monday 25 March 2019 15:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Brunssum, Netherlands
Contact:

Re: Irrigation garden with buienradar

Post by dheuts »

It's working! Thanks a lot.

Was already reading on DzVents wiki and just read the solution while you posted it here.
Thanks a lot! I think I'm going to learn in DzVents, this is great.
Raspberry Pi 4 With Domoticz - RFXCom - Tuya Wifi LED lights - Chuango Alarm - Zwave+ - Zigbee2MQTT - Anna Thermostat - Broadlink IR, P1 - Eufy Robo Vacuum - Worx Robo Mower
ceesjan
Posts: 3
Joined: Saturday 02 May 2015 1:17
Target OS: Linux
Domoticz version: 2020.2
Location: Schiphol
Contact:

Re: Irrigation garden with buienradar

Post by ceesjan »

What is the brand and type of your Irrigation computer (Beregeningscomputer) or is it home made ??
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest