Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. Time awareness and scheduling events

Time awareness and scheduling events

Scheduled Pinned Locked Moved Development
30 Posts 8 Posters 9.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    ToSa
    Code Contributor
    wrote on last edited by ToSa
    #1

    As started here.

    Looking at the TimeAwareSensor example essentially everything is there for time synchronization. Once the callback is set with the initial call to requestTime, any subsequent time packets received from the gateway would be used to update/adjust the internal time accordingly.
    The only adjustments needed to get to a real time synchronization would be to let the gateway (or rather the controller) broadcast the time every x minutes and ensure that the sensor listens to the time packets even if they are not addressed to the nodeID but broadcasted (today only TIME packets addressed to the specific node are handled).

    I've done these changes here and will do some testing.

    To schedule events the question is how to store the schedule with a minimum footprint in EEPROM. Keeping hour:minute should be sufficient. Storing these in a byte each is a waste of space (only 5 bits for 0-23h and 6 bits for 0-59m needed or 11 bits for 0-1439m). Looking at usual scenarios you need a bitmap for the weekdays (schedule for Mo/We/Fr only) which takes another 7 bit. With that three bytes are minimum and leave 6 bist for additional purposes.
    For home automation you would usually want to have a way to tell if the event should be executed on a public holiday (1 bit) and you want to have a way to tell if it should be executed when you are on vacation (1 bit) - I'll explain in a later post how public holiday and vacation could be determined.

    Each event should probably include some kind of payload (what to do). To keep this simple I'd propose a single byte payload and let the callback function in the main sketch decide what to do with it.

    This is a request for ideas before I start coding any of this!!!

    YveauxY 1 Reply Last reply
    0
    • epierreE Offline
      epierreE Offline
      epierre
      Hero Member
      wrote on last edited by
      #2

      I am searching for a way to receive atomic clock... to no success do far...

      z-wave - Vera -> Domoticz
      rfx - Domoticz <- MyDomoAtHome <- Imperihome
      mysensors -> mysensors-gw -> Domoticz

      T 1 Reply Last reply
      0
      • epierreE epierre

        I am searching for a way to receive atomic clock... to no success do far...

        T Offline
        T Offline
        ToSa
        Code Contributor
        wrote on last edited by
        #3

        @epierre You lose accuracy during RF transmission to the nodes, therefore I didn't go for DCF77 but told the controller (RPi) to fetch the time via NTF from the internet. If you really need DCF77 then have a look here - should be pretty easy to implement on the gateway and send to sensors from there or even on specific sensor nodes that need very accurate time.

        1 Reply Last reply
        0
        • hekH Offline
          hekH Offline
          hek
          Admin
          wrote on last edited by
          #4

          I've ordered a couple of RTC modules that could be a optional accessory for a node. Distributing server time is still needed.

          korttomaK 1 Reply Last reply
          0
          • hekH hek

            I've ordered a couple of RTC modules that could be a optional accessory for a node. Distributing server time is still needed.

            korttomaK Offline
            korttomaK Offline
            korttoma
            Hero Member
            wrote on last edited by
            #5

            @hek I ordered a few of these -> http://www.ebay.com/itm/191276972230 hoping they can serve the same purpose.

            • Tomas
            korttomaK 1 Reply Last reply
            0
            • marceltrapmanM Offline
              marceltrapmanM Offline
              marceltrapman
              Mod
              wrote on last edited by
              #6

              The only disadvantage I see with these modules is that their libraries eat a lot of memory.

              I wanted to use them in combination with an lcd but at this point it is either one or the other but not both...

              I hope that flash memory will bring some relief...

              Fulltime Servoy Developer
              Parttime Moderator MySensors board

              I use Domoticz as controller for Z-Wave and MySensors (previously Indigo and OpenHAB).
              I have a FABtotum to print cases.

              1 Reply Last reply
              0
              • T ToSa

                As started here.

                Looking at the TimeAwareSensor example essentially everything is there for time synchronization. Once the callback is set with the initial call to requestTime, any subsequent time packets received from the gateway would be used to update/adjust the internal time accordingly.
                The only adjustments needed to get to a real time synchronization would be to let the gateway (or rather the controller) broadcast the time every x minutes and ensure that the sensor listens to the time packets even if they are not addressed to the nodeID but broadcasted (today only TIME packets addressed to the specific node are handled).

                I've done these changes here and will do some testing.

                To schedule events the question is how to store the schedule with a minimum footprint in EEPROM. Keeping hour:minute should be sufficient. Storing these in a byte each is a waste of space (only 5 bits for 0-23h and 6 bits for 0-59m needed or 11 bits for 0-1439m). Looking at usual scenarios you need a bitmap for the weekdays (schedule for Mo/We/Fr only) which takes another 7 bit. With that three bytes are minimum and leave 6 bist for additional purposes.
                For home automation you would usually want to have a way to tell if the event should be executed on a public holiday (1 bit) and you want to have a way to tell if it should be executed when you are on vacation (1 bit) - I'll explain in a later post how public holiday and vacation could be determined.

                Each event should probably include some kind of payload (what to do). To keep this simple I'd propose a single byte payload and let the callback function in the main sketch decide what to do with it.

                This is a request for ideas before I start coding any of this!!!

                YveauxY Offline
                YveauxY Offline
                Yveaux
                Mod
                wrote on last edited by
                #7

                @ToSa maybe I'm missing something but if I understand you right you require scheduling at the sensor, right?

                http://yveaux.blogspot.nl

                T 1 Reply Last reply
                0
                • YveauxY Yveaux

                  @ToSa maybe I'm missing something but if I understand you right you require scheduling at the sensor, right?

                  T Offline
                  T Offline
                  ToSa
                  Code Contributor
                  wrote on last edited by
                  #8

                  @Yveaux Right - I mentioned the garden watering in another post - I want the sensor to be aware of the schedule to reduce the single points of failure to a minimum - and avoid bad surprises getting back home after vacation :) That means the sensor is able to execute even if the controller is broken or the gateway is broken or the network connectivity is broken due to a relaying node in the middle etc.

                  1 Reply Last reply
                  0
                  • hekH Offline
                    hekH Offline
                    hek
                    Admin
                    wrote on last edited by
                    #9

                    The trend in HA now moves towards pushing some of the "intelligence" to the nodes. This creates autonomous units that can actually work for a while without contacting and relying on the "mothership".

                    YveauxY 1 Reply Last reply
                    0
                    • hekH hek

                      The trend in HA now moves towards pushing some of the "intelligence" to the nodes. This creates autonomous units that can actually work for a while without contacting and relying on the "mothership".

                      YveauxY Offline
                      YveauxY Offline
                      Yveaux
                      Mod
                      wrote on last edited by
                      #10

                      @hek I also want to be able to switch on my lights when my gateway is down, but when we want to move intelligence to the nodes (eg make them programmable using rules as seen in another discussion) we have to think upfront what the implications are and how to implement this. I should not rush some kind of schedule rules now, without thinking over the whole concept first.

                      http://yveaux.blogspot.nl

                      hekH T 2 Replies Last reply
                      0
                      • YveauxY Yveaux

                        @hek I also want to be able to switch on my lights when my gateway is down, but when we want to move intelligence to the nodes (eg make them programmable using rules as seen in another discussion) we have to think upfront what the implications are and how to implement this. I should not rush some kind of schedule rules now, without thinking over the whole concept first.

                        hekH Offline
                        hekH Offline
                        hek
                        Admin
                        wrote on last edited by
                        #11

                        @Yveaux

                        Fully agree. That why we're discussing the concepts :facepunch: :)

                        YveauxY 1 Reply Last reply
                        0
                        • YveauxY Yveaux

                          @hek I also want to be able to switch on my lights when my gateway is down, but when we want to move intelligence to the nodes (eg make them programmable using rules as seen in another discussion) we have to think upfront what the implications are and how to implement this. I should not rush some kind of schedule rules now, without thinking over the whole concept first.

                          T Offline
                          T Offline
                          ToSa
                          Code Contributor
                          wrote on last edited by
                          #12

                          @Yveaux

                          This is a request for ideas before I start coding any of this!!!

                          :)
                          time awareness was straight forward based on existing functionality (even if I would still argue that it should be an integral part of the sensor code and not require separate code in the custom sketch).The rules engine requires much more prep work and smart ideas.

                          In an earlier project I ended up with the following (not saying that this is the best approach - just to start the discussion):

                          • simple memory manager assigning memory addresses so that you can remotely request or set a variable in memory the same way you do today with sensors (think about a memory address having its own sensor-id on the node)
                          • rules to set variables on the same node or on remote nodes (or on the gateway/controller)
                          • rules triggered by schedule or triggered by events (button clicked / temperature changed / ...)
                          • no need to trigger rules remotely - you can get that by setting a variable remotely and have a rule listening on changes to that variable (node A with the light switch telling node B with the relay to turn on the light)
                          • gateway is always made aware of what's going on but usually not required for the execution

                          The problem is that the "setup" of the network and the specific nodes gets way more complex - easy to do for software developers but hard to do for a "normal" user.

                          1 Reply Last reply
                          0
                          • hekH hek

                            @Yveaux

                            Fully agree. That why we're discussing the concepts :facepunch: :)

                            YveauxY Offline
                            YveauxY Offline
                            Yveaux
                            Mod
                            wrote on last edited by Yveaux
                            #13

                            @hek yeah yeah... The initial post sounded quite concrete and is limited to time and scheduling. Therefore I wanted to broaden things a bit. But I guess this will automatically happen in a few hours anyway, if you get what I mean ;-)

                            http://yveaux.blogspot.nl

                            1 Reply Last reply
                            0
                            • T Offline
                              T Offline
                              ToSa
                              Code Contributor
                              wrote on last edited by
                              #14

                              @hek any plans to setup a "dev_1.5" branch or something similar? If we continue adding major functionality changes to 1.4 it will never get "ready" :)

                              hekH 1 Reply Last reply
                              0
                              • T ToSa

                                @hek any plans to setup a "dev_1.5" branch or something similar? If we continue adding major functionality changes to 1.4 it will never get "ready" :)

                                hekH Offline
                                hekH Offline
                                hek
                                Admin
                                wrote on last edited by
                                #15

                                @ToSa

                                Yes, only ONE page left to document (API). Then I'll release 1.4 (push it to master) and we can have development for our selves again ;)

                                1 Reply Last reply
                                0
                                • korttomaK korttoma

                                  @hek I ordered a few of these -> http://www.ebay.com/itm/191276972230 hoping they can serve the same purpose.

                                  korttomaK Offline
                                  korttomaK Offline
                                  korttoma
                                  Hero Member
                                  wrote on last edited by
                                  #16

                                  @korttoma said:

                                  @hek I ordered a few of these -> http://www.ebay.com/itm/191276972230 hoping they can serve the same purpose.

                                  I have now been playing with one of these for a few hour and I really like it. Running an LCD and TinyRTC on the same I2C bus and it is working fine.
                                  Need some more time on the sketch before I mount everything in a box. The goal is a scene controller
                                  / clock / info display by the bed.
                                  I was thinking of adding the knock sensor as a "clapper" device but I don't think I can pull of the code so that it would keep updating the clock as often as I would like.

                                  • Tomas
                                  hekH 1 Reply Last reply
                                  0
                                  • korttomaK korttoma

                                    @korttoma said:

                                    @hek I ordered a few of these -> http://www.ebay.com/itm/191276972230 hoping they can serve the same purpose.

                                    I have now been playing with one of these for a few hour and I really like it. Running an LCD and TinyRTC on the same I2C bus and it is working fine.
                                    Need some more time on the sketch before I mount everything in a box. The goal is a scene controller
                                    / clock / info display by the bed.
                                    I was thinking of adding the knock sensor as a "clapper" device but I don't think I can pull of the code so that it would keep updating the clock as often as I would like.

                                    hekH Offline
                                    hekH Offline
                                    hek
                                    Admin
                                    wrote on last edited by
                                    #17

                                    @korttoma

                                    Yes, received mine yesterday but haven't had time to play with it yet.
                                    The DS3231 I got seems to have a build-in temp-sensor also.

                                    1 Reply Last reply
                                    0
                                    • greglG Offline
                                      greglG Offline
                                      gregl
                                      Hero Member
                                      wrote on last edited by
                                      #18

                                      Probably not something you need guys, but something i did the other day - a sketch to request the time from Vera and set an RTC.

                                      My requirement is to keep the RTC synced when daylight saving changes, so sync would be at 2:01 Sundays.

                                      https://codebender.cc/sketch:48244

                                      hekH 1 Reply Last reply
                                      1
                                      • greglG gregl

                                        Probably not something you need guys, but something i did the other day - a sketch to request the time from Vera and set an RTC.

                                        My requirement is to keep the RTC synced when daylight saving changes, so sync would be at 2:01 Sundays.

                                        https://codebender.cc/sketch:48244

                                        hekH Offline
                                        hekH Offline
                                        hek
                                        Admin
                                        wrote on last edited by
                                        #19

                                        @gregl

                                        Thanks @gregl, was just about to create something similar :)

                                        1 Reply Last reply
                                        0
                                        • greglG Offline
                                          greglG Offline
                                          gregl
                                          Hero Member
                                          wrote on last edited by
                                          #20

                                          No prob... you can remove the bugs ive added ;-)

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          13

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.1k

                                          Posts


                                          Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular