Logic Machine Forum
different value throughout the day - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: different value throughout the day (/showthread.php?tid=1439)

Pages: 1 2


different value throughout the day - benthoma - 10.06.2018

Is it possible to send diffrent values from a 1bit signal compared to the time of day? 


RE: different value throughout the day - Erwin van der Zwart - 10.06.2018

Hi,

Yes that is possible, but can you describe your task in more detail?

BR,

Erwin


RE: different value throughout the day - benthoma - 11.06.2018

(10.06.2018, 20:13)Erwin van der Zwart Wrote: Hi,

Yes that is possible, but can you describe your task in more detail?

BR,

Erwin


Event based script that sends a value between for example 08-13 another value between 13-14 and so on.


Also needs a script that does the same automatically, but that I can start/stop via a bit value or a scene value.



RE: different value throughout the day - Erwin van der Zwart - 11.06.2018

Hi,

Try this:
Code:
now = os.date('*t')
if now.hour >= 8 and now.hour < 13 then
   grp.write('1/1/1', true)
elseif now.hour >= 13 and now.hour < 14 then
   grp.write('1/1/1', false)
end
For enable/disable script above from 1 bit use this: (sample is assuming event script script above is called 'timebasedevent')
Code:
if event.getvalue() == true then
  script.enable('timebasedevent')
else
  script.disable('timebasedevent')
end
BR,

Erwin


RE: different value throughout the day - benthoma - 12.06.2018

(11.06.2018, 21:59)Erwin van der Zwart Wrote: Hi,

Try this:
Code:
now = os.date('*t')
if now.hour >= 8 and now.hour < 13 then
   grp.write('1/1/1', true)
elseif now.hour >= 13 and now.hour < 14 then
   grp.write('1/1/1', false)
end
For enable/disable script above from 1 bit use this: (sample is assuming event script script above is called 'timebasedevent')
Code:
if event.getvalue() == true then
  script.enable('timebasedevent')
else
  script.disable('timebasedevent')
end
BR,

Erwin

Thank you .


RE: different value throughout the day - benthoma - 16.06.2018

(11.06.2018, 21:59)Erwin van der Zwart Wrote: Hi,

Try this:
Code:
now = os.date('*t')
if now.hour >= 8 and now.hour < 13 then
   grp.write('1/1/1', true)
elseif now.hour >= 13 and now.hour < 14 then
   grp.write('1/1/1', false)
end
For enable/disable script above from 1 bit use this: (sample is assuming event script script above is called 'timebasedevent')
Code:
if event.getvalue() == true then
  script.enable('timebasedevent')
else
  script.disable('timebasedevent')
end
BR,

Erwin
The first code. Can we do different things with a true value and a false value?


RE: different value throughout the day - Erwin van der Zwart - 17.06.2018

Hi,

We can do whatever you like to do with script, but can you specify your question better?

BR,

Erwin


RE: different value throughout the day - benthoma - 18.06.2018

(17.06.2018, 10:59)Erwin van der Zwart Wrote: Hi,

We can do whatever you like to do with script, but can you specify your question better?

BR,

Erwin

Sounds good.
Event based script that sends a value between for example 08-13 another value between 13-14 and so on.
Sends different values with a 1bit true/false


RE: different value throughout the day - Erwin van der Zwart - 18.06.2018

Hi,

That is already in the sample i gave you (:

BR,

Erwin


RE: different value throughout the day - benthoma - 21.06.2018

(18.06.2018, 09:54)Erwin van der Zwart Wrote: Hi,

That is already in the sample i gave you (:

BR,

Erwin

Sorry my fault.


RE: different value throughout the day - Dré - 05.04.2021

I want almost do the same.

I want just active the light, only between 5.30 am and 10 am.
my question is, is it also possible to do it with hours and minutes?
i m sure it is, but im just a beginner, who will convert my Gira Homeserver to the LM.


RE: different value throughout the day - khalil - 05.04.2021

(05.04.2021, 10:03)Dré Wrote: I want almost do the same.

I want just active the light, only between 5.30 am and 10 am.
my question is, is it also possible to do it with hours and minutes?
i m sure it is, but im just a beginner, who will convert my Gira Homeserver to the LM.

did you try the schedule?


RE: different value throughout the day - Dré - 05.04.2021

(05.04.2021, 14:00)khalil Wrote:
(05.04.2021, 10:03)Dré Wrote: I want almost do the same.

I want just active the light, only between 5.30 am and 10 am.
my question is, is it also possible to do it with hours and minutes?
i m sure it is, but im just a beginner, who will convert my Gira Homeserver to the LM.

did you try the schedule?

I hope not to use the schedule this time, i want to use the script, for making it happened.


RE: different value throughout the day - admin - 06.04.2021

You can convert current time to a number of minutes passed since 0:00 and use it in your calculations. Use this example to check if current time is between 5:30 and 10:00
Code:
function tominutes(h, m)
  return h * 60 + m
end

now = os.date('*t')
mins = tominutes(now.hour, now.min)

if mins >= tominutes(5, 30) and mins <= tominutes(10, 0) then
  -- do something here
end



RE: different value throughout the day - Dré - 25.04.2021

Thank you admin, i wasn't able to try it, but it works fine so far.


RE: different value throughout the day - ricole87 - 12.06.2021

(16.06.2018, 17:57)benthoma Wrote:
(11.06.2018, 21:59)Erwin van der Zwart Wrote: Hi,

Try this:
Code:
now = os.date('*t')
if now.hour >= 8 and now.hour < 13 then
   grp.write('1/1/1', true)
elseif now.hour >= 13 and now.hour < 14 then
   grp.write('1/1/1', false)
end
For enable/disable script above from 1 bit use this: (sample is assuming event script script above is called 'timebasedevent')
Code:
if event.getvalue() == true then
  script.enable('timebasedevent')
else
  script.disable('timebasedevent')
end
BR,

Erwin
The first code. Can we do different things with a true value and a false value?


Hi ! i tried the first script, saved and enabled but it seem the object value given not changing. Tried to change value as hours follow the current timing, object value also no changed. Do i have to set the script run and check everytime (this wat i read throught out the search regard scripting)


this what in my script

now = os.date('*t')
if now.hour >= 8 and now.hour < 13 then
   grp.write('0/0/100', true)
elseif now.hour >= 13 and now.hour < 14 then
   grp.write('0/0/100', false)
end


RE: different value throughout the day - admin - 12.06.2021

What script type are you using for this? Have you considered using schedulers instead?


RE: different value throughout the day - ricole87 - 15.06.2021

(12.06.2021, 07:51)admin Wrote: What script type are you using for this? Have you considered using schedulers instead?

Hi ! Thank you for your advise. I also found the schedule app is more convenient to set on off for the object.  Smile. I got it going


RE: different value throughout the day - nikola2704 - 08.07.2023

Hi all, I see this is an older tread, but i will give it a shot.

I would like to put my light at some places from the motion sensor at day full light and night dimmed. At the motion sensor ( Basalte aura ) i can chose there control day = 1 and night is 0

I tried the script and schedulers as mentioned above, but non of them will change my status. I'm a bit new in to KNX and scripting.

now = os.date('*t')
if now.hour >= 7 and now.hour < 22 then
grp.write('10/0/3', true)
elseif now.hour >= 22 and now.hour < 7 then
grp.write('10/0/3', false)
end


RE: different value throughout the day - Erwin van der Zwart - 09.07.2023

elseif now.hour >= 22 and now.hour < 7 then…

This is impossible, a value can never be greater as 22 AND at the same time lower as 7 (:

Use: elseif now.hour >= 22 or now.hour < 7 then