Change timer of dzVents script with Telegram

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

Moderator: leecollings

Post Reply
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Change timer of dzVents script with Telegram

Post by gschmidt »

Hi,

I was wondering if it is possible to change/feed the timer (times/dates) of a dzVents script with Telegram?

I have a dzVents script which activates a Switch (which triggers node-red to send a google cast audio stream to a certain google home device)
We use it as a wake-up alarm
The timer in the dzVents script is currently:

Code: Select all

    on = 
    {
        timer = 
        {
            'at 06:45 on mon,tue,wed,thu,fri',
        },
    },
The goal is to send a text string from Telegram to Domoticz which changes the Timer of the dzVents script:

Examples:
  • 'at 06:45 on mon,tue,wed,thu,fri',
  • 'at 07:00',
  • 'at 06:45 on tue,wed,fri', 'at 08:00 on tue,thu',
User avatar
waltervl
Posts: 5883
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Change timer of dzVents script with Telegram

Post by waltervl »

I cannot not help with this Dzvents but why not use the timer function on the switch itself to trigger node red?
https://www.domoticz.com/wiki/Managing_ ... ice_Timers

And with the API it should be possible to change a timer.
But onfortunately I cannot find the timer modify api, only some commands for scenes... https://www.domoticz.com/wiki/Domoticz_ ... 28timer.29

Edit: there is this command that could work. Can you trigger that with a telegram message?
Update parameters for a specific schedule(timer) for Devices

Code: Select all

  /json.htm?type=command&param=updatetimer&idx=timerID&active=true&timertype=3&hour=0&min=20&randomness=true&command=0&days=12345



But @waaren will come with the right solution.... :-)
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Change timer of dzVents script with Telegram

Post by waaren »

gschmidt wrote: Saturday 13 March 2021 12:45 I was wondering if it is possible to change/feed the timer (times/dates) of a dzVents script with Telegram?
Yes; if you know a method to get the payload of telegram into a device, variable or can send an http to domoticz.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Change timer of dzVents script with Telegram

Post by gschmidt »

waaren wrote: Saturday 13 March 2021 13:32
gschmidt wrote: Saturday 13 March 2021 12:45 I was wondering if it is possible to change/feed the timer (times/dates) of a dzVents script with Telegram?
Yes; if you know a method to get the payload of telegram into a device, variable or can send an http to domoticz.
Busy with it, using "node-red-contrib-telegrambot". I already get a raw message in Node-Red like this:

Code: Select all

{"payload":{"chatId":11875XXXXX,"messageId":9,"type":"message","content":"'at 6:45 on mon,tue,wed,thu,fri',","date":1615849045},"originalMessage":{"message_id":9,"from":{"id":11875XXXXX,"is_bot":false,"first_name":"Gerben","last_name":"Schmidt","username":"GXXXXX","language_code":"nl"},"chat":{"id":11875XXXXX,"first_name":"Gerben","last_name":"Schmidt","username":"GXXXXX","type":"private"},"date":1615849045,"text":"'at 6:45 on mon,tue,wed,thu,fri',"},"_msgid":"27272aea.2574a6"}
Last edited by gschmidt on Tuesday 16 March 2021 8:09, edited 1 time in total.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Change timer of dzVents script with Telegram

Post by waaren »

gschmidt wrote: Tuesday 16 March 2021 0:00 Busy with it, using "node-red-contrib-telegrambot". I already get a raw message in Node-Red like this:
Nice!

Maybe @Firewizard can help to send the relevant payload to domoticz with MQTT

with something like

Code: Select all

{"command":"customevent", "event":"changeTimer","data":"your payload"} # preferred methof 
{"command": "setuservariable", "idx": 1, "value": "your payload" } # indirect via uservariable
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest