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. Controllers
  3. Home Assistant
  4. Receiving only UTC time from Home Assistant controller

Receiving only UTC time from Home Assistant controller

Scheduled Pinned Locked Moved Home Assistant
5 Posts 2 Posters 2.2k Views 2 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.
  • proddyP Offline
    proddyP Offline
    proddy
    wrote on last edited by
    #1

    I'm not sure if this is a MySensors or Home Assistant issue, but using the example at https://www.mysensors.org/build/display to read the time from my HA controller, it always pulls the UTC time where in the MySensors library documentation here it states that void receiveTime(unsigned long ts); returns ts "Adjusted for timezone by controller."

    I have the time_zone parameter correctly configured in my Home Assistant's configuration.yaml file.

    As a workaround I have the sensor node convert the time using this piece of code:

    #include <Timezone.h>
    #include <TimeLib.h>
    TimeChangeRule CEST = { "CEST", Last, Sun, Mar, 12, 120 }; // Central European Summer Time, 2 hrs offset
    TimeChangeRule CET = { "CET ", Last, Sun, Nov, 5, 60 };   // Central European Standard Time, 1 hr offset
    Timezone CE(CEST, CET);
    : 
    :     
    TimeChangeRule * tcr;
    time_t t = CE.toLocal(controllerTime, &tcr);
    RTC.set(t);
    

    But it would good to know if its a bug or I'm just doing something incorrect?

    martinhjelmareM 1 Reply Last reply
    0
    • proddyP proddy

      I'm not sure if this is a MySensors or Home Assistant issue, but using the example at https://www.mysensors.org/build/display to read the time from my HA controller, it always pulls the UTC time where in the MySensors library documentation here it states that void receiveTime(unsigned long ts); returns ts "Adjusted for timezone by controller."

      I have the time_zone parameter correctly configured in my Home Assistant's configuration.yaml file.

      As a workaround I have the sensor node convert the time using this piece of code:

      #include <Timezone.h>
      #include <TimeLib.h>
      TimeChangeRule CEST = { "CEST", Last, Sun, Mar, 12, 120 }; // Central European Summer Time, 2 hrs offset
      TimeChangeRule CET = { "CET ", Last, Sun, Nov, 5, 60 };   // Central European Standard Time, 1 hr offset
      Timezone CE(CEST, CET);
      : 
      :     
      TimeChangeRule * tcr;
      time_t t = CE.toLocal(controllerTime, &tcr);
      RTC.set(t);
      

      But it would good to know if its a bug or I'm just doing something incorrect?

      martinhjelmareM Offline
      martinhjelmareM Offline
      martinhjelmare
      Plugin Developer
      wrote on last edited by
      #2

      @Paul-Derbyshire

      Hi!

      This is a bug or at least a deviation from the mysensors API. We should fix it. Should be just a matter of using the correct time function, I think.

      proddyP 1 Reply Last reply
      0
      • martinhjelmareM martinhjelmare

        @Paul-Derbyshire

        Hi!

        This is a bug or at least a deviation from the mysensors API. We should fix it. Should be just a matter of using the correct time function, I think.

        proddyP Offline
        proddyP Offline
        proddy
        wrote on last edited by
        #3

        @martinhjelmare is this something I can help contribute too?

        martinhjelmareM 1 Reply Last reply
        0
        • proddyP proddy

          @martinhjelmare is this something I can help contribute too?

          martinhjelmareM Offline
          martinhjelmareM Offline
          martinhjelmare
          Plugin Developer
          wrote on last edited by
          #4

          @Paul-Derbyshire

          Yes! Make a PR to pymysensors repository at github. I think calendar.timegm(time.localtime()) should return the correct time.

          proddyP 1 Reply Last reply
          0
          • martinhjelmareM martinhjelmare

            @Paul-Derbyshire

            Yes! Make a PR to pymysensors repository at github. I think calendar.timegm(time.localtime()) should return the correct time.

            proddyP Offline
            proddyP Offline
            proddy
            wrote on last edited by
            #5

            @martinhjelmare I made a PR. https://github.com/theolind/pymysensors/pull/80

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


            12

            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