Set Overlay on Weather
Automate setting the overlay based on the weather.
Built by Galadril
Published 2 January 2025 · updated 2 January 2025 · 2 downloads
🔄 Activation and Timing:
-
The script is marked as active by
active = true. -
It executes every 1 minute as specified in the trigger section
timer = {'every 1 minutes'}.
-
📝 Logging:
-
Logs are generated with the marker "AWTRIX3_OVERLAY" to identify entries related to this script.
-
The logging level is set to
domoticz.LOG_INFO, ensuring that informational messages are captured.
-
-
☁️ Weather Data Acquisition:
-
Checks if the "AWTRIX3 - Power" device is "On". If not, the script stops execution.
-
Retrieves weather information from the "Outside Weather" device.
-
Logs the current temperature and weather forecast if available. Logs an error if data is missing.
-
-
⚙️ Overlay Setting Logic:
-
Determines the overlay level based on weather forecast conditions:
-
Snow ❄️: Sets overlay level to 10.
-
Rain 🌧️: Sets overlay level to 20.
-
Drizzle 🌦️: Sets overlay level to 30.
-
Storm 🌩️: Sets overlay level to 40.
-
Thunder 🌩️: Sets overlay level to 50.
-
Frost ❄️ (Temperature < 0°C): Sets overlay level to 60.
-
Clear 🌞: Sets overlay level to 0.
-
-
Logs the determined condition and selected overlay level for informational purposes.
-
-
🎚️ Overlay Adjustment:
-
Fetches the "AWTRIX3 - Overlay" selector device.
-
Sets the overlay level on the device if it differs from the current setting.
-
Logs any changes made to the overlay level.
-
🏁 Purpose: This script synchronizes the AWTRIX3 clock overlay with real-time weather conditions, providing a visual indication of weather phenomena. This feature can enhance awareness in daily life by displaying current weather right on the device.
More information:
Domoticz:
www.domoticz.com
Domoticz AWTRIX3 Plugin:
https://github.com/galadril/Domoticz-AWTRIX3-Plugin
RJM9ALL6ALzX.json · 3.7 KB
-- dzVents script to set Awtrix3 clock overlay based on weather
return {
active = true, -- Set script as active
-- Trigger section: run the script every 1 minute
on = {
timer = {
'every 1 minutes'
}
},
logging = {
level = domoticz.LOG_INFO,
marker = "AWTRIX3_OVERLAY"
},
execute = function(domoticz)
local powerDevice = domoticz.devices("AWTRIX3 - Power")
if not powerDevice or powerDevice.state ~= "On" then
return
end
-- Fetch the weather device
local weatherDevice = domoticz.devices("Outside Weather") -- 'Your outside weather device'
if not weatherDevice then
domoticz.log("Weather device not found!", domoticz.LOG_ERROR)
return
end
-- Extract weather details
local temp = weatherDevice.temperature
local forecast = weatherDevice.forecastString
if temp then
domoticz.log("Current temperature: " .. temp .. "°C", domoticz.LOG_INFO)
else
domoticz.log("Temperature data is missing!", domoticz.LOG_ERROR)
end
if forecast then
domoticz.log("Weather forecast: " .. forecast, domoticz.LOG_INFO)
else
domoticz.log("Forecast data is missing!", domoticz.LOG_ERROR)
end
-- Determine overlay based on weather conditions
local overlayLevel
if forecast and forecast:find("Snow") then
overlayLevel = 10 -- "Snow"
domoticz.log("Forecast indicates snow. Setting overlay to 'Snow'.", domoticz.LOG_DEBUG)
elseif forecast and forecast:find("Rain") then
overlayLevel = 20 -- "Rain"
domoticz.log("Forecast indicates rain. Setting overlay to 'Rain'.", domoticz.LOG_DEBUG)
elseif forecast and forecast:find("Drizzle") then
overlayLevel = 30 -- "Drizzle"
domoticz.log("Forecast indicates drizzle. Setting overlay to 'Drizzle'.", domoticz.LOG_DEBUG)
elseif forecast and forecast:find("Storm") then
overlayLevel = 40 -- "Storm"
domoticz.log("Forecast indicates storm. Setting overlay to 'Storm'.", domoticz.LOG_DEBUG)
elseif forecast and forecast:find("Thunder") then
overlayLevel = 50 -- "Thunder"
domoticz.log("Forecast indicates thunder. Setting overlay to 'Thunder'.", domoticz.LOG_DEBUG)
elseif temp and temp < 0 then
overlayLevel = 60 -- "Frost"
domoticz.log("Temperature below freezing. Setting overlay to 'Frost'.", domoticz.LOG_DEBUG)
else
overlayLevel = 0 -- "Off" (Clear)
domoticz.log("No specific weather condition detected or data missing. Setting overlay to 'Off'.", domoticz.LOG_DEBUG)
end
-- Fetch the Awtrix3 selector switch for overlay
local awtrixOverlaySelector = domoticz.devices("AWTRIX3 - Overlay")
if not awtrixOverlaySelector then
domoticz.log("Awtrix3 overlay selector switch not found!", domoticz.LOG_ERROR)
return
end
domoticz.log("Overlay selector device found: " .. awtrixOverlaySelector.name, domoticz.LOG_DEBUG)
-- Set the overlay level on the Awtrix3 device
if awtrixOverlaySelector.level ~= overlayLevel then
awtrixOverlaySelector.switchSelector(overlayLevel)
domoticz.log("Set Awtrix3 overlay to level: " .. overlayLevel, domoticz.LOG_INFO)
else
domoticz.log("Awtrix3 overlay already set to level: " .. overlayLevel, domoticz.LOG_DEBUG)
end
domoticz.log("Awtrix3 Weather Overlay script finished.", domoticz.LOG_INFO)
end
}