Hi,
I'd find very useful for Domoticz to export a global variable within settings to scripts.
I use several LUA scripts, and it will be great if scripts can get a variable table within the Telegram API key and chat_id defines in Setup -> Settings -> Notifications, so it's not needed to duplicate those variables inside external configuration files.
SOLVED: Telegram chatid and api key available to scripts ? Topic is solved
Moderators: leecollings, remb0
- psubiaco
- Posts: 233
- Joined: Monday 20 August 2018 9:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Italy
- Contact:
SOLVED: Telegram chatid and api key available to scripts ?
Last edited by psubiaco on Monday 15 March 2021 19:04, edited 3 times in total.
Paolo
--
I use DomBus modules to charge EV car, get a full alarm system, control heat pump, fire alarm detection, lights and much more. Video
Facebook page - Youtube channel
--
I use DomBus modules to charge EV car, get a full alarm system, control heat pump, fire alarm detection, lights and much more. Video
Facebook page - Youtube channel
- waltervl
- Posts: 6677
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2025.1
- Location: NL
- Contact:
Re: Telegram chatid and api key available to scripts ?
The settings are available with an API call for Lua with curl. See also viewtopic.php?t=35048
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Telegram chatid and api key available to scripts ?
With sufficient authorization it's quite easy to get these values from domoticz via the API.psubiaco wrote: Sunday 14 March 2021 16:37 Hi,
I'd find very useful for Domoticz to export a global variable within settings to scripts.
I use several LUA scripts, and it will be great if scripts can get a variable table within the Telegram API key and chat_id defines in Setup -> Settings -> Notifications, so it's not needed to duplicate those variables inside external configuration files.
See below dzVents (100% Lua) example
Code: Select all
local scriptVar = 'settings'
return
{
on =
{
timer =
{
'every minute'
},
httpResponses =
{
scriptVar,
}
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = scriptVar,
},
execute = function(dz, item)
if item.isTimer then
dz.openURL({
url = dz.settings['Domoticz url'] .. '/json.htm?type=settings',
callback = scriptVar,
})
return
end
if item.isHTTPResponse and item.json then
-- dz.utils.dumpTable(item.json) -- Dumps all values to log
dz.log('TelegramAPI: '.. item.json.TelegramAPI, dz.LOG_DEBUG )
dz.log('TelegramCHAT ID: ' ..item.json.TelegramChat, dz.LOG_DEBUG )
else
dz.log('There was a problem handling the request', dz.LOG_ERROR)
dz.log(item, dz.LOG_DEBUG)
end
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
- psubiaco
- Posts: 233
- Joined: Monday 20 August 2018 9:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Italy
- Contact:
Re: Telegram chatid and api key available to scripts ?
Hi waaren,
thanks a lot for your reply. I didn't know that settings were available in json!
Having a table/dict variable with all settings is easier to access, but json is a good workaround as well.
Paolo
thanks a lot for your reply. I didn't know that settings were available in json!
Having a table/dict variable with all settings is easier to access, but json is a good workaround as well.
Paolo
Paolo
--
I use DomBus modules to charge EV car, get a full alarm system, control heat pump, fire alarm detection, lights and much more. Video
Facebook page - Youtube channel
--
I use DomBus modules to charge EV car, get a full alarm system, control heat pump, fire alarm detection, lights and much more. Video
Facebook page - Youtube channel
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Telegram chatid and api key available to scripts ?
Have a look at this wiki page to see what else is available via the API in json returnspsubiaco wrote: Sunday 14 March 2021 18:11 Hi waaren,
thanks a lot for your reply. I didn't know that settings were available in json!
Having a table/dict variable with all settings is easier to access, but json is a good workaround as well.
Paolo
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Who is online
Users browsing this forum: Google [Bot] and 1 guest