Page 1 of 1

Alert Sensor as input. [Solved!]

Posted: Monday 17 October 2022 23:10
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
}


Re: Alert Sensor as input.

Posted: Monday 17 October 2022 23:39
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
}

Re: Alert Sensor as input.

Posted: Wednesday 19 October 2022 18:51
by magicduck
Thanks :) This works like a charm ! :D