Hi,
Need to convert sunset as a $ as 20:30 f.I.
Search the wiki, but can’t find it.
Convert sunset as $
Moderator: leecollings
-
- Posts: 25
- Joined: Friday 19 April 2019 22:29
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.1
- Location: Netherlands
- Contact:
Convert sunset as $
Dz-beta | Dashticz 3.8.10 BETA | Tradfri | RF-Link | Z-Wave | Harmony | Unify | P1 |
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Convert sunset as $
Can you please elaborate a bit on this? Based on this one line, I have no clear idea on what you try to achieve.
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
-
- Posts: 25
- Joined: Friday 19 April 2019 22:29
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.1
- Location: Netherlands
- Contact:
Re: Convert sunset as $
Hi waaren,
Thanks for you're answer. This is a part of the code.
Want to have a action between 2 different moments.
Thanks for you're answer. This is a part of the code.
Want to have a action between 2 different moments.
Code: Select all
local onTime = 'sunset'
local ofTime = '23:00'
local printerTime = '09:00'
commandArray = {}
if os.date('%H:%M') >= onTime and os.date('%H:%M') <= ofTime then
if otherdevices['Wie is er thuis'] == 'Off' then
print ("We zijn NIET thuis")
Dz-beta | Dashticz 3.8.10 BETA | Tradfri | RF-Link | Z-Wave | Harmony | Unify | P1 |
- erem
- Posts: 230
- Joined: Tuesday 27 March 2018 12:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2021.1
- Location: Amsterdam/netherlands
- Contact:
Re: Convert sunset as $
Regards,
Rob
Rob
-
- Posts: 25
- Joined: Friday 19 April 2019 22:29
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.1
- Location: Netherlands
- Contact:
Re: Convert sunset as $
Thanks Rob,
Wil try that, let you know the result.
Dick
Wil try that, let you know the result.
Dick
Dz-beta | Dashticz 3.8.10 BETA | Tradfri | RF-Link | Z-Wave | Harmony | Unify | P1 |
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Convert sunset as $
Dickey wrote: ↑Wednesday 31 March 2021 12:23 Hi waaren,
Thanks for you're answer. This is a part of the code.
Want to have a action between 2 different moments.
Code: Select all
local onTime = 'sunset' local ofTime = '23:00' local printerTime = '09:00' commandArray = {} if os.date('%H:%M') >= onTime and os.date('%H:%M') <= ofTime then if otherdevices['Wie is er thuis'] == 'Off' then print ("We zijn NIET thuis")
OK. sunset moment is passed to Lua as minutes since midnight in _G.timeofday.SunsetInMinutes
This will give you two options.
Code: Select all
commandArray = {}
local onTime = _G.timeofday.SunsetInMinutes -- sunset as minutes since midnight
local now = os.date('%H') * 60 + os.date('%M') -- now in minutes since midnight
local ofTime = '23:00'
local printerTime = '09:00'
if now >= onTime and os.date('%H:%M') <= ofTime then
if otherdevices['Wie is er thuis'] == 'Off' then
print ("We zijn NIET thuis")
end
end
return commandArray
Code: Select all
local function minutesToTime(minutes)
local h = math.floor(minutes / 60)
local hh = ('0' .. h):sub(-2)
local mm = ('0' .. minutes - (h * 60)):sub(-2)
return hh .. ':' .. mm
end
commandArray = {}
local onTime = minutesToTime(_G.timeofday.SunsetInMinutes) -- sunset as hh:mm
print(onTime)
local ofTime = '23:00'
local printerTime = '09:00'
if os.date('%H:%M') >= onTime and os.date('%H:%M') <= ofTime then
if otherdevices['Wie is er thuis'] == 'Off' then
print ("We zijn NIET thuis")
end
end
return commandArray
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
-
- Posts: 25
- Joined: Friday 19 April 2019 22:29
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.1
- Location: Netherlands
- Contact:
Re: Convert sunset as $
You been very busy
Tnx for that.
I used opt 2. Did not know the ... minutesToTime(_G.timeofday.SunsetInMinutes).
This is new piece:
Appreciate you're help.
Thanks a lot.

I used opt 2. Did not know the ... minutesToTime(_G.timeofday.SunsetInMinutes).
This is new piece:
Code: Select all
local ofTime = '23:00'
local printerTime = '09:00'
local function minutesToTime(minutes)
local h = math.floor(minutes / 60)
local hh = ('0' .. h):sub(-2)
local mm = ('0' .. minutes - (h * 60)):sub(-2)
return hh .. ':' .. mm
end
commandArray = {}
local onTime = minutesToTime(_G.timeofday.SunsetInMinutes) -- sunset as hh:mm
if now >= onTime and os.date('%H:%M') <= ofTime then
if otherdevices['Wie is er thuis'] == 'Off' then
print ("We zijn NIET thuis")
commandArray['Group:Hoofdverlichting']='Inactive'
Thanks a lot.
Dz-beta | Dashticz 3.8.10 BETA | Tradfri | RF-Link | Z-Wave | Harmony | Unify | P1 |
Who is online
Users browsing this forum: No registered users and 1 guest