Alert Sensor as input. [Solved!]

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

Moderator: leecollings

Post Reply
magicduck
Posts: 36
Joined: Sunday 11 February 2018 13:25
Target OS: -
Domoticz version:
Location: Longwy, France
Contact:

Alert Sensor as input. [Solved!]

Post by magicduck »

Hello,

I have the following sensor (EcoDevices) that can have 2 values (General Alert sensor ->

1 -> Heures Creuses
2 -> Heures Pleines

I don't know how to make simple actions about this sensor in dzVents (seems I am one of the strange people who likes to know how to do that).

Here is my code... If you can help me a bit :)

Code: Select all

return {
        on = {
                devices = {
                        'EDF Tarif en cours'
                }
        },
        execute = function(domoticz, tarif)
                domoticz.notify('Tarifs ' .. tarif.value, domoticz.HIGH)
                if (tarif.value == '(1) Heures Creuses') then
                    -- Heure Creuses
                    domoticz.devices('SW HC').switchOn()
                else
                    -- Off
                    domoticz.devices('SW HC').switchOff()
                end
        end
}

Last edited by magicduck on Wednesday 19 October 2022 18:51, edited 1 time in total.
plugge

Re: Alert Sensor as input.

Post by plugge »

Assuming that I understand what you have and want, and 'EDF Tarif en cours' is a Alert sensor, then you should use ".text" to get the value stored.
(See the dzVents manual: https://www.domoticz.com/wiki/DzVents:_ ... ert_sensor)

Code: Select all

return {
        on = {
                devices = {
                        'EDF Tarif en cours'
                }
        },
        execute = function(domoticz, tarif)
                domoticz.notify('Tarifs ' .. tarif.text, domoticz.PRIORITY_HIGH)
                if tarif.text == '(1) Heures Creuses'
		then
                    -- Heure Creuses
                    domoticz.devices('SW HC').switchOn()
                else
                    -- Off
                    domoticz.devices('SW HC').switchOff()
                end
        end
}
magicduck
Posts: 36
Joined: Sunday 11 February 2018 13:25
Target OS: -
Domoticz version:
Location: Longwy, France
Contact:

Re: Alert Sensor as input.

Post by magicduck »

Thanks :) This works like a charm ! :D
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest