GithubHelp home page GithubHelp logo

Comments (24)

pkissling avatar pkissling commented on June 3, 2024 2

Can’t you use the time zone setting as set in HA? I have the same issue since I work on a different continent from where my house is.

thanks for the hint. that might be feasible and might make the configuration/implementation easier.
i'll have a look into it in the next couple of days

from clock-weather-card.

rad2000 avatar rad2000 commented on June 3, 2024 2

If it doesn't add too much complexity, I'd love the ability to specify any sensor for the date/time. I have a wall panel where I'd like to display the time and weather in different cities where I have family. I can currently do this with the weather since I can specify any sensor, but I can't for the time.

from clock-weather-card.

pkissling avatar pkissling commented on June 3, 2024 1

thanks for the request.
when i initially implemented the card, i realised that sensor.time is optional in home assistant and must be configured explicitly.
hence i could not rely on the sensor being available in every HA instance. thus i decided to get the time from the current browser.

what i could do though, is to allow providing an optional property time_sensor: sensor.time and read the current time from there. but since sensor.time only holds the time, i would additionally need sensor.date to show the weekday and the corresponding date, which makes the configuration a bit clunky since a user would have to configure both values time_sensor and date_sensor to make it work. and if a user only configures either property, the card will not work properly

from clock-weather-card.

dunxd avatar dunxd commented on June 3, 2024 1

Much prefer the suggestion to use any sensor - this allows more flexibility. Is there a way to have a default that can be overridden?

from clock-weather-card.

miholobolo avatar miholobolo commented on June 3, 2024

I would love to have this as well. In my case i use the clock on a screen device that is cut from the internet, and has no reliable internal clock. I was hoping that could use the time of the HA.

from clock-weather-card.

dunxd avatar dunxd commented on June 3, 2024

It's odd that sensor.time is not enabled by default in HA, but anyway...

I see how it makes the config a bit clunky. Can you set defaults so if either time_sensor or date_sensor were missing something would still be displayed?

from clock-weather-card.

Progaros avatar Progaros commented on June 3, 2024

I use LibreWolf Browser which only uses GMT 0. I would really like an an option to define a custom offset or timezone

(get browser time zone, calculate difference to user setting and set new time)

from clock-weather-card.

teddy-ptmedia avatar teddy-ptmedia commented on June 3, 2024

I also would like to be able to set my home time zone for the same reasons. I’m away from home and my HA should show the time at my home and not my local time where I am offsite.

from clock-weather-card.

Ih8rain2 avatar Ih8rain2 commented on June 3, 2024

Can’t you use the time zone setting as set in HA? I have the same issue since I work on a different continent from where my house is.

from clock-weather-card.

pedromfa avatar pedromfa commented on June 3, 2024

@pkissling any development on this? Would really appreciate to have the host machine local time option. :) Thank you so much for this card!

from clock-weather-card.

Progaros avatar Progaros commented on June 3, 2024

i currently use this userscript with e.g. violentmonkey:

change YOUR_DOMAIN and germanTimeZoneOffset

// ==UserScript==
// @name         Deutsche Zeitzone
// @namespace   Violentmonkey Scripts
// @match       https://YOUR_DOMAIN
// @version      0.1
// @description  Überschreibt das Date-Objekt, um die deutsche Zeitzone zu verwenden
// @author       Me
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    const today = new Date();
    const month = today.getMonth() + 1; // Januar ist 0, daher +1
    const day = today.getDate();
    const hour = today.getHours();

    let isSummerTime;

    if (month > 3 && month < 10) { // Sommerzeit gilt von April bis September
      isSummerTime = true;
    } else if (month === 3 && day >= 29 && hour >= 2) { // letzter Sonntag im März um 2 Uhr
      isSummerTime = true;
    } else if (month === 10 && day <= 25 && hour < 3) { // letzter Sonntag im Oktober um 3 Uhr
      isSummerTime = true;
    } else {
      isSummerTime = false;
    }

    const germanTimeZoneOffset = isSummerTime ? -120 : -60; // Deutsche Zeitzone ist UTC+1 (+2 während Sommerzeit)
    const originalDate = Date;

    function getGermanDate(...args) {
        if (args.length === 0) {
            const now = new originalDate();
            return new originalDate(now.getTime() + (now.getTimezoneOffset() - germanTimeZoneOffset) * 60000);
        } else {
            return new originalDate(...args);
        }
    }

    // Überschreibe das Date-Objekt
    const newDate = function(...args) {
        return getGermanDate(...args);
    };

    // Kopiere die Prototypen und statischen Methoden
    Object.setPrototypeOf(newDate, originalDate);
    Object.setPrototypeOf(newDate.prototype, originalDate.prototype);
    for (const prop of Object.getOwnPropertyNames(originalDate)) {
        if (typeof originalDate[prop] === 'function') {
            newDate[prop] = originalDate[prop].bind(originalDate);
        } else {
            Object.defineProperty(newDate, prop, Object.getOwnPropertyDescriptor(originalDate, prop));
        }
    }

    // Date-Objekt überschreiben
    Date = newDate;
    window.Date = newDate;
})();

from clock-weather-card.

pkissling avatar pkissling commented on June 3, 2024

@pkissling any development on this? Would really appreciate to have the host machine local time option. :) Thank you so much for this card!

i did the code changes today (introducing an attribute use_browser_time which can be set to false to use time from time_zone configured in HA.
i will have to do some testing tomorrow and will afterwards release a new version

#177

@dunxd @rad2000 if you want a feature to configure a dedicated time and date sensor, feel free to create a new issue 👍🏻

from clock-weather-card.

pedromfa avatar pedromfa commented on June 3, 2024

@pkissling thank you so much! 😎

from clock-weather-card.

pedromfa avatar pedromfa commented on June 3, 2024

Screenshot_2023-04-24-08-39-09-448-edit_io homeassistant companion android
Hi again. Now it seems there's a 12h difference between Ha time and the one your card displays. See screenshot attached. Perhaps some error in the background? Appreciated the efforts here @pkissling. 😎😉

from clock-weather-card.

teddy-ptmedia avatar teddy-ptmedia commented on June 3, 2024

from clock-weather-card.

pedromfa avatar pedromfa commented on June 3, 2024

Both time format gives me the wrong time by +12h

from clock-weather-card.

pkissling avatar pkissling commented on June 3, 2024

Both time format gives me the wrong time by +12h

Can you please give additional information?
Your current time zone (browser), your current time, the time zone configured in HA and the browser you are using. i want to try to reproduce the problem

from clock-weather-card.

pedromfa avatar pedromfa commented on June 3, 2024

My current time zone is UTC+7 (12:42lt). My HA host is UTC+1(0642lt). The card shoud be showing 0642lt but it's showing 1842lt. And I'm using the android companion app to access my instance. Sorry for all this trouble. 😁

from clock-weather-card.

pkissling avatar pkissling commented on June 3, 2024

What time zone is configured in your HA instance? e.g. time_zone: Europe/Berlin

from clock-weather-card.

pedromfa avatar pedromfa commented on June 3, 2024

Screenshot_2023-04-24-16-17-13-942_io homeassistant companion android

from clock-weather-card.

dunxd avatar dunxd commented on June 3, 2024

Just updated after getting back from my holiday, but tested by changing the timezone on my phone. Works as expected which is awesome. Am I right in thinking you achieved this by applying the timezone for HA to the time coming from the browser?

IMHO use_browser_time should be false by default as it should correspond to the location that weather is being shown for in the same card!

from clock-weather-card.

pkissling avatar pkissling commented on June 3, 2024

Just updated after getting back from my holiday, but tested by changing the timezone on my phone. Works as expected which is awesome. Am I right in thinking you achieved this by applying the timezone for HA to the time coming from the browser?

IMHO use_browser_time should be false by default as it should correspond to the location that weather is being shown for in the same card!

yes, agreed. i have this on the radar for the next major version of the card. by default the card would then fetch the current time from HA instead of the browser and a user would be able to disable it by setting use_browser_time: false.

the reason i didn't do this in the current release is because i did not want to break existing dashboards by changing the default logic of where the card gets the time from
https://github.com/pkissling/clock-weather-card/milestone/3

from clock-weather-card.

pkissling avatar pkissling commented on June 3, 2024

Screenshot_2023-04-24-16-17-13-942_io homeassistant companion android

thanks for the feedback. i released 1.0.15 today. hope its fixed now. otherwise please open a new issue

from clock-weather-card.

pedromfa avatar pedromfa commented on June 3, 2024

@pkissling it's wonderful after last update! Many many thanks for this! 😎

from clock-weather-card.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.