home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.17k stars 30.2k forks source link

datetime.datetime.now() is in UTC and not local time zone in 0.118 #43412

Closed sermayoral closed 3 years ago

sermayoral commented 3 years ago

The problem

datetime.datetime.now () function, before 0.118, it gave me the local time. After 0.118 i get an hour less (UTC). Seems to be a python datetime issue with timezones.

Environment

Problem-relevant configuration.yaml

python_script:

Traceback/Error logs

Traceback/Error

Additional information

It's a problem similar to https://github.com/home-assistant/core/issues/43337. Looking at the history, I have observed that, since I updated Home Assistant to 0.118, I am experiencing the reported problem.

@balloob I have tagged you as you asked me :-). Thanks!

rkennedy commented 3 years ago

I've noticed something similar as of 0.118, but I think the issue might go beyond Python.

I have a command_line sensor that runs a bash script including the instruction printf '%(%Y-%m-%d %H:%M:%S%z)T' -2, which gives the time the shell was invoked. Until I upgraded, it always gave the local time.

When Home Assistant (supervised) runs the script to update the sensor, it gives the current UTC time. For example, 2020-11-20 02:57:02+0000. If I log in to the SSH container and run the script myself, though, it gives the current local time. For example, 2020-11-19 20:57:02-0600. In both cases, the TZ environment variable is set to my local time zone.

If there were a Python problem with datetime, I wouldn't expect the shell to also have the problem. Perhaps it's a deeper environmental issue instead.

DendelX commented 3 years ago

Same behavior here!

ludeeus commented 3 years ago

Are you sure your locale is correct?

Even with your example printf '%(%Y-%m-%d %H:%M:%S%z)T' -2 I get the output in my TZ (both in the homeassistant container, and in the SSH container)

tggman commented 3 years ago

The datetime.datetime.now() function in my Python script also returns UTC instead of local time (+6 hours in my case). That function returned local time prior to upgrading to HA 0.118.

balloob commented 3 years ago

@tggman tracked in #43412

sermayoral commented 3 years ago

@ludeeus in my case, yes, I have my locale set to Europe/Madrid.

Home Assistant Logs Registry show me the right local time. Supervisor logs show me UTC time (it has always been in that way, it's not new), but python_script , after 0.118, give me the UTC time, so all my python_scripts that use datetime.datetime.now() are not working propertly

Mariusthvdb commented 3 years ago

fwiw, because of that behavior, I've always used (/had to use) this in all of my python scripts, and this goes way back. I see no change in python scripts using datetime.datetime.now() at all since 118

utc_offset = hass.states.get('sensor.utc_offset').state
timeDifference = float(utc_offset)

    if (state.state == filter or debug):
        dt = state.last_changed + datetime.timedelta(hours= timeDifference)
        time = '%02d:%02d' % (dt.hour,dt.minute)

      # If state changed in the past days show the date too
        if dt.date() < datetime.datetime.now().date():
            time = '{} {}'.format('%02d/%02d' % (dt.day,dt.month),time)

with the sensor.utc_offset being

      utc_offset:
        friendly_name: Utc offset
        value_template: >
          {{now().utcoffset().total_seconds()/3600}}
ludeeus commented 3 years ago

@sermayoral can you try running ha core rebuild?

balloob commented 3 years ago

Marius is correct. datetime.datetime.now() is not tied into the timezone set in Home Assistant. It is tied to your system timezone.

Your system timezone should be set by Home Assistant if you run Supervised / OS. If that is wrong, ha core rebuild as Ludeeus suggests, should set it.

Also make sure the timezone is right when you go to config -> General.

sermayoral commented 3 years ago

@ludeeus sure!

➜  /workspace hassio homeassistant rebuild
⣾ Processing... Done.

Command completed successfully. 

The process has finished, Home Assistant restarted but same issue :-(

@balloob I'm running Supervised, so my timezone should be set by Home Assistant. ha core rebuild didn't work :-(

My timezone is right in Config -> General:

imagen

A logger output of a python_script [logger.warning('datetime.datetime.now() output: {}'.format(datetime.datetime.now()))]:

imagen

System timezone is right in the Home Assistant Environment:

➜  /workspace date
Fri Nov 20 16:15:14 CET 2020

System timezone is right in the Debian OS as well:

$ date
vie nov 20 16:18:22 CET 2020
sermayoral commented 3 years ago

@Mariusthvdb I'm pretty sure datetime.datetime.now() has been returning the local time (right timezone) until I updated to 0.118. At least in my case...

Mariusthvdb commented 3 years ago

well, ymmv, but in my setup I've been struggling with that ever since (or even sometime before) this

had a hard coded +1 there, which obviously didn't help during DS time periods. So finally decided to use the Utc sensor. Which fixed it ever since. Using OS, (Hassio at the time), if that's of any relevance.

sermayoral commented 3 years ago

@Mariusthvdb My mileage vary. Sorry.

I'm sorry for your problems more than 3 years ago, but there is anything wrong with python datetime in 0.118 Home Assistant system. Issue that didn't happen in 0.117-. @tggman and @DendelX seem to have the same issue. Something has been broken.

It's 18:24 right now in my country (local time). I have tried the same function in all the PCs in my home, different OS, etc. All of them are returning the right local time:

python test.py
Windows 10 Python 3.7 datetime.datetime.now(): 2020-11-20 18:27:15.408757

With the images attached above, it is shown that the timezone is correctly set, both on the Home Assistant system and on the Debian system. But python datetime is not working as expected.

Additionally. In the Home Assistant System, I have checked this:

imagen

The python 2.7 installed in the HA system gives me the correct local time! So, it's clear the HA system has the timezone right. So it seems to affect python_script integration only.

But this is not working well, neither with time.localtime(), sorry:

imagen

sermayoral commented 3 years ago

Sorry I had a mistake with the keyboard :-(

sermayoral commented 3 years ago

@balloob I think this is the PR that has caused this issue: https://github.com/home-assistant/core/pull/42146

amelchio commented 3 years ago

@sermayoral What do you see if you press "LOAD FULL HOME ASSISTANT LOG" to see the raw logs in that last image?

sermayoral commented 3 years ago

@amelchio in the full log i can see UTC time:

2020-11-20 17:43:03 WARNING (SyncWorker_47) [homeassistant.components.python_script.gestor_climatizacion.py] time.localtime(): time.struct_time(tm_year=2020, tm_mon=11, tm_mday=20, tm_hour=17, tm_min=43, tm_sec=3, tm_wday=4, tm_yday=325, tm_isdst=0)

balloob commented 3 years ago

This test passes on 117, 118 and 119dev.

async def test_datetime_now(hass, caplog):
    """Test time.sleep warns once."""
    caplog.set_level(logging.WARNING)
    now = dt_util.now().replace(microsecond=0, tzinfo=None)
    source = """
hass.states.set('bla.bla', datetime.datetime.now().replace(microsecond=0).isoformat())
"""

    hass.async_add_executor_job(execute, hass, "test.py", source, {})
    await hass.async_block_till_done()

    assert hass.states.get("bla.bla").state == now.isoformat()
sermayoral commented 3 years ago

@balloob yeah, the time is the same, but they are shown in different timezones:

imagen

sermayoral commented 3 years ago

@balloob can you do a test that compare dt_util.now().hour and datetime.datetime.now().hour on 117, 118 and 119? But it must be restricted_python datetime classes.

sermayoral commented 3 years ago

Well, I think I already understand everything. The problem is not the system timezone. I have also tried doing a {{now ()}} in the template engine, and it also returns the local time (with the correct timezone).

The problem only happens with the datetime you use inside python_scripts. This datetime does not have the defined system timezone associated with it (for this reason it shows the UTC time instead of the local time).

The funny thing is why the datetime that I used inside the python_scripts showed me the local time before 0.118.0? Quite a mystery ... Perhaps it is produced by the changes of https://github.com/home-assistant/core/pull/42146, but as much as I look at the PR, I do not see anything strange in it.

I think the solution to this issue is to set the timezone in the time module of restricted_python. Something like this:

In https://github.com/home-assistant/core/blob/dev/homeassistant/components/python_script/__init__.py

set:

>>> os.environ['TZ'] = 'Europe/London' (value of the timezone set in config -> general)
>>> time.tzset()

But i'm not sure how to do this :-(

amelchio commented 3 years ago

The problem is not the system timezone.

For Home Assistant "the system" is the Docker container. I believe all your findings are consistent with the TZ environment variable not being properly set inside the container.

sermayoral commented 3 years ago

@amelchio Thanks. I undestand, but two points about it:

ludeeus commented 3 years ago

Can you run docker exec homeassistant printenv | grep TZ ?

sermayoral commented 3 years ago

docker exec homeassistant printenv | grep TZ

sermayoral commented 3 years ago

@ludeeus sure!

$ docker exec homeassistant printenv | grep TZ
TZ=Europe/Madrid
ludeeus commented 3 years ago

Well, that's good! but does not explain anything since that should be used for datetime.datetime.now()

Did you list all your configured integrations somewhere (including custom_component)? if not can you list them here?

sermayoral commented 3 years ago

@ludeeus I swear I have been using datetime.datetime.now() for a long time and it has always given me the correct time (my heating system depends on this command, together with time.tm_isdst). As soon as I upgraded to 0.118.0, this problem started.

amelchio commented 3 years ago

We are trying to find out what's wrong, nobody is saying you broke it.

Can you try adding this sensor to verify that TZ is also correct in the running Home Assistant process:

sensor:
  - platform: command_line
    name: timezone
    command: '/bin/sh -c "printenv|grep TZ="'

It should give the same TZ=Europe/Madrid value.

ludeeus commented 3 years ago

And this one would be interresting:

docker exec homeassistant python3 -c "import datetime; print(datetime.datetime.now())"
sermayoral commented 3 years ago

And this one would be interresting:

docker exec homeassistant python3 -c "import datetime; print(datetime.datetime.now())"

@ludeeus here you are:

docker exec homeassistant python3 -c "import datetime; print(datetime.datetime.now())"
2020-11-21 11:17:10.436357

This time does not have the timezone.

ludeeus commented 3 years ago

Something seems to overwrite how it does that.

This is from inside my homeassistant container:

bash-5.0# export TZ=Europe/Riga
bash-5.0# python3 -c "import datetime; print(datetime.datetime.now())"
2020-11-21 13:28:06.134757
bash-5.0# export TZ=Europe/Madrid
bash-5.0# python3 -c "import datetime; print(datetime.datetime.now())"
2020-11-21 12:28:44.161060

UTC would be 11:28 at the point of posting this.

Can you try what @amelchio sugested? And this as well:

docker exec homeassistant python3 -m pip freeze
sermayoral commented 3 years ago

We are trying to find out what's wrong, nobody is saying you broke it.

Can you try adding this sensor to verify that TZ is also correct in the running Home Assistant process:

sensor:
  - platform: command_line
    name: timezone
    command: '/bin/sh -c "printenv|grep TZ="'

It should give the same TZ=Europe/Madrid value.

imagen

sermayoral commented 3 years ago

Something seems to overwrite how it does that.

This is from inside my homeassistant container:

bash-5.0# export TZ=Europe/Riga
bash-5.0# python3 -c "import datetime; print(datetime.datetime.now())"
2020-11-21 13:28:06.134757
bash-5.0# export TZ=Europe/Madrid
bash-5.0# python3 -c "import datetime; print(datetime.datetime.now())"
2020-11-21 12:28:44.161060

UTC would be 11:28 at the point of posting this.

Can you try what @amelchio sugested? And this as well:

docker exec homeassistant python3 -m pip freeze
$ docker exec homeassistant python3 -m pip freeze ``` abodepy==1.1.0 accuweather==0.0.11 acme==1.9.0 Adafruit-Blinka==5.8.0 adafruit-circuitpython-bmp280==3.1.1 adafruit-circuitpython-busdevice==5.0.1 adafruit-circuitpython-mcp230xx==2.2.2 adafruit-circuitpython-pca9685==3.3.2 adafruit-circuitpython-register==1.9.1 Adafruit-DHT @ file:///usr/src/dht Adafruit-GPIO==1.0.3 Adafruit-PlatformDetect==2.22.1 Adafruit-PureIO==1.1.7 Adafruit-SHT31==1.0.2 adal==1.2.5 adb-shell==0.2.1 adext==0.3 adguardhome==0.4.2 advantage-air==0.2.1 aenum==2.2.4 afsapi==0.0.4 agent-py==0.0.23 aio-geojson-client==0.13 aio-geojson-geonetnz-quakes==0.12 aio-geojson-geonetnz-volcano==0.5 aio-geojson-nsw-rfs-incidents==0.3 aio-georss-client==0.6 aio-georss-gdacs==0.4 aioambient==1.2.1 aioasuswrt==1.3.0 aioazuredevops==1.3.5 aiobotocore==0.11.1 aiocache==0.11.1 aiocoap==0.4b3 aiodns==2.0.0 aioeafm==0.1.2 aioesphomeapi==2.6.3 aiofiles==0.6.0 aioflo==0.4.1 aiofreepybox==0.0.8 aioftp==0.12.0 aiogithubapi==2.0.0 aioguardian==1.0.4 aioharmony==0.2.6 aiohomekit==0.2.54 aiohttp==3.7.1 aiohttp-cors==0.7.0 aiohue==2.1.0 aioimaplib==0.7.15 aiokafka==0.6.0 aiokef==0.2.16 aiolifx==0.6.7 aiolifx-effects==0.2.2 aionotify==0.2.0 aionotion==1.1.0 aionursery==0.3.0 aiopulse==0.4.0 aiopvapi==1.6.14 aiopvpc==2.0.2 aiopylgtv==0.3.3 aiorecollect==0.2.1 aioshelly==0.5.1 aiosqlite==0.16.0 aioswitcher==1.2.1 aiounifi==25 aioymaps==1.1.0 airly==1.0.0 alabaster==0.7.12 aladdin-connect==0.3 alarmdecoder==1.13.2 alpha-vantage==2.2.0 Ambiclimate==0.2.1 amcrest==1.7.0 android-backup==0.2.0 androidtv==0.0.54 anel-pwrctrl-homeassistant==0.0.1.dev2 anthemav==1.1.10 apcaccess==0.0.13 apns2==0.3.0 appdirs==1.4.4 apprise==0.8.9 aprslib==0.6.46 aqualogic==1.0 arcam-fmj==0.5.3 argcomplete==1.12.1 argh==0.26.2 arris-tg2492lg==1.1.0 arrow==0.17.0 asmog==0.0.6 asterisk-mbox==0.5.0 astral==1.10.1 astroid==2.4.2 async-generator==1.10 async-timeout==3.0.1 async-upnp-client==0.14.13 asynccmd==0.2.4 asyncio==3.4.3 asyncio-dgram==1.1.1 asyncpysupla==0.0.5 asyncssh==2.4.2 atenpdu==0.3.0 atomicwrites==1.4.0 attrs==19.3.0 aurorapy==0.2.6 Authlib==0.15.2 av==8.0.2 avri-api==0.1.7 axis==41 azure-common==1.1.26 azure-core==1.9.0 azure-eventhub==5.1.0 azure-servicebus==0.50.3 Babel==2.9.0 backoff==1.10.0 baidu-aip==1.6.6.0 base36==0.1.1 basicmodem==0.7 batinfo==0.4.2 bcrypt==3.1.7 beautifulsoup4==4.6.0 bellows==0.20.3 bimmer-connected==0.7.13 bitstring==3.1.7 bizkaibus==0.1.1 blebox-uniapi==1.3.2 blinkpy==0.16.3 BlinkStick==1.1.8 blockchain==1.4.4 bluepy==1.3.0 blurhash==1.1.4 bond-api==0.1.8 boto3==1.9.252 botocore==1.13.14 bravia-tv==1.0.8 broadlink==0.16.0 brother==0.1.18 brotlipy==0.7.0 brottsplatskartan==0.0.1 brunt==0.1.3 bs4==0.0.1 bsblan==0.4.0 bt-proximity==0.2 bthomehub5-devicelist==0.1.1 btlewrap==0.1.0 btsmarthub-devicelist==0.2.0 buienradar==1.0.4 cached-property==1.5.2 cachetools==2.0.1 caldav==0.6.1 casttube==0.2.1 cattrs==1.1.1 cbor2==5.2.0 cchardet==2.1.7 certifi==2020.11.8 cffi==1.14.3 chardet==3.0.4 circuit-webhook==1.0.1 ciscomobilityexpress==0.3.3 ciso8601==2.1.3 class-registry==2.1.2 clearpasspy==1.0.2 click==7.1.2 click-datetime==0.2 click-log==0.2.0 click-plugins==1.1.1 clx-sdk-xms==1.0.0 CO2Signal==0.4.2 coinbase==2.1.0 coinmarketcap==5.0.3 colorama==0.4.4 coloredlogs==10.0 colorlog==4.5.0 colorthief==0.2.1 colorzero==1.1 concord232==0.15 config==0.5.0.post0 ConfigArgParse==0.11.0 connect-box==0.2.8 construct==2.9.45 convertdate==2.3.0 coronavirus==1.1.1 coverage==5.3 crc16==0.1.1 crccheck==1.0 crcmod==1.7 crimereports==1.0.1 croniter==0.3.36 cryptography==3.2 curve25519-donna==1.3 cycler==0.10.0 Cython==0.29.21 datadog==0.15.0 datapoint==0.9.5 dateparser==1.0.0 DateTime==4.3 debugpy==1.1.0 decorator==4.4.2 deepmerge==0.1.1 defusedxml==0.6.0 deluge-client==1.7.1 demjson==2.2.4 denonavr==0.9.5 Deprecated==1.2.10 devolo-home-control-api==0.16.0 dicttoxml==1.7.4 dill==0.2.7.1 directv==0.3.0 discogs-client==2.3.0 discord.py==1.4.1 distro==1.5.0 dlipower==0.7.165 dnspython==1.15.0 dnspython3==1.15.0 docopt==0.6.2 docutils==0.15.2 DoorBirdPy==2.1.0 dovado==0.4.1 dsmr-parser==0.18 DTLSSocket==0.1.11 dwdwfsapi==1.0.3 dweepy==0.3.0 dynalite-devices==0.1.46 eagle200-reader==0.2.4 ebusdpy==0.0.16 ecdsa==0.16.1 ecoaliface==0.4.0 ed25519==1.5 eebrightbox==0.0.4 elgato==0.2.0 eliqonline==1.2.2 elkm1-lib==0.8.8 emoji==0.5.4 emulated-roku==0.2.1 enocean==0.50.0 enturclient==0.2.1 enum-compat==0.0.3 env-canada==0.2.4 envoy-reader==0.16.2 envs==1.3 ephem==3.7.7.0 epson-projector==0.2.3 epsonprinter==0.0.9 eternalegypt==0.0.12 evohome-async==0.3.5.post1 extras==1.0.0 fake-useragent==0.1.11 fastdotcom==0.0.3 feedparser-homeassistant==5.2.2.dev1 fiblary3==0.1.7 filters==1.3.2 fints==1.0.1 fitbit==0.3.1 fixerio==1.0.0a0 fixtures==3.0.0 Flask==1.1.2 flux-led==0.22 fnvhash==0.1.0 foobot-async==0.3.2 fortiosapi==0.10.8 freesms==0.1.2 fritzconnection==1.3.4 future==0.18.2 garminconnect==0.1.16 gcloud==0.18.3 geizhals==0.0.9 geniushub-client==0.6.30 geographiclib==1.50 geojson==2.5.0 geojson-client==0.4 geopy==1.21.0 georss-client==0.11 georss-generic-client==0.4 georss-ign-sismologia-client==0.2 georss-qld-bushfire-alert-client==0.3 get-mac==0.8.2 getmac==0.8.2 gios==0.1.4 gitterpy==0.1.7 glances-api==0.2.0 gntp==1.0.3 goalzero==0.1.4 gogogate2-api==2.0.3 google-api-core==1.23.0 google-api-python-client==1.6.4 google-auth==1.23.0 google-auth-oauthlib==0.4.2 google-cloud-pubsub==2.1.0 google-cloud-texttospeech==0.4.0 google-nest-sdm==0.1.14 googleapis-common-protos==1.52.0 googlemaps==2.5.1 goslide-api==0.5.1 gps3==0.33.3 graphql-subscription-manager==0.3.6 graphviz==0.15 greeclimate==0.10.3 greeneye-monitor==2.1 greenwavereality==0.5.1 griddypower==0.1.0 growattServer==0.1.1 grpc-google-iam-v1==0.12.3 grpcio==1.31.0 gstreamer-player==1.1.2 gTTS-token==1.1.4 guppy3==3.1.0 h11==0.11.0 h2==2.6.2 ha-ffmpeg==2.0 ha-philipsjs==0.0.8 habitipy==0.2.0 hacs-frontend==202009091732 hangups==0.4.11 HAP-python==3.0.0 hass-nabucasa==0.37.2 hass-splunk==0.1.1 HATasmota==0.0.32 haversine==2.3.0 hbmqtt==0.9.6 hdate==0.9.12 heatmiserV3==1.1.18 herepy==2.0.0 hikvision==0.4 hkavr==0.0.5 hlk-sw16==0.0.9 hole==0.5.1 holidays==0.10.3 home-assistant-frontend==20201111.2 # Editable install with no version control (homeassistant==0.118.2) -e /usr/src/homeassistant homeassistant-pyozw==0.1.10 homeconnect==0.6.3 homematicip==0.12.1 horimote==0.4.1 hpack==3.0.0 html-table-parser-python3==0.1.5 httmock==1.4.0 http-ece==1.1.0 http3==0.6.7 httpcore==0.12.1 httplib2==0.18.1 httpsig==1.3.0 httpx==0.16.1 huawei-lte-api==1.4.12 humanfriendly==8.2 Hydrawiser==0.2 hyper==0.7.0 hyperframe==3.2.0 hyperion-py==0.3.0 iammeter==0.1.7 iaqualink==0.3.4 ibm-cloud-sdk-core==1.0.0 ibm-watson==4.0.1 ibmiotf==0.3.4 icmplib==1.2.2 idna==2.10 ifaddr==0.1.7 iglo==1.2.7 ihcsdk==2.7.0 imageio==2.9.0 imagesize==1.2.0 importlib-metadata==1.7.0 incomfort-client==0.4.0 inflection==0.5.1 influxdb==5.2.3 influxdb-client==1.8.0 iniconfig==1.1.1 intelhex==2.3.0 iperf3==0.1.11 iso8601==0.1.13 isodate==0.6.0 isort==5.6.4 itsdangerous==1.1.0 jeepney==0.6.0 Jinja2==2.11.2 jmespath==0.10.0 josepy==1.5.0 Js2Py==0.70 jsonpatch==1.26 jsonpath==0.82 jsonpickle==1.4.1 jsonpointer==2.0 jsonrpc-async==1.1.1 jsonrpc-base==1.1.0 jsonrpc-websocket==1.2.1 justbackoff==0.6.0 jws==0.1.3 kafka-python==2.0.2 kaiterra-async-client==0.0.2 keba-kecontact==1.1.0 keyring==21.2.0 keyrings.alt==3.4.0 kiwiki-client==0.1.1 kiwisolver==1.3.1 konnected==1.2.0 korean-lunar-calendar==0.2.1 lakeside==0.12 lazy-object-proxy==1.4.3 libcst==0.3.14 libpurecool==0.6.3 libpyfoscam==1.0 libpyvivotek==0.4.0 librouteros==3.0.0 libsoundtouch==0.8.0 life360==4.1.1 liffylights==0.9.4 lightify==1.0.7.2 lightwave==0.19 limitlessled==1.1.3 linecache2==1.0.0 linode-api==4.1.9b1 lmnotify==0.0.4 locationsharinglib==4.1.0 logi-circle==0.2.2 lomond==0.3.3 london-tube-status==0.2 luftdaten==0.6.4 lupupy==0.0.18 lw12==0.9.2 lxml==4.6.1 lyft-rides==0.2 magicseaweed==1.0.3 Markdown==3.3.3 MarkupSafe==1.1.1 Mastodon.py==1.5.1 matplotlib==3.3.3 matrix-client==0.3.2 maxcube-api==0.1.0 mbddns==0.1.2 mccabe==0.6.1 mcstatus==2.3.0 MechanicalSoup==0.6.0 messagebird==1.2.0 metar==1.7.0 meteoalertapi==0.1.6 meteofrance-api==0.1.1 mficlient==0.3.0 miflora==0.7.0 millheater==0.3.4 minio==4.0.9 mitemp-bt==0.0.3 mock==4.0.2 ms-cv==0.1.1 msgpack==0.6.2 msrest==0.6.19 msrestazure==0.6.4 mt-940==4.23.0 multidict==5.0.2 mutagen==1.45.1 mychevy==2.0.1 mycroftapi==2.0 mypy-extensions==0.4.3 mysqlclient==2.0.1 n26==0.2.7 nad-receiver==0.0.12 natsort==7.0.1 nclib==1.0.0 ndms2-client==0.0.11 nessclient==0.9.15 netaddr==0.8.0 netdata==0.2.0 netdisco==2.8.2 netifaces==0.10.9 neurio==0.3.1 nexia==0.9.4 nextcloudmonitor==1.1.0 niko-home-control==0.2.1 niluclient==0.1.2 noaa-coops==0.1.8 notify-events==1.0.4 nsapi==3.0.4 nsw-fuel-api-client==1.0.10 nuheat==0.3.0 numato-gpio==0.8.0 numpy==1.19.2 oasatelematics==0.3 oauth2client==4.0.0 oauthlib==3.1.0 objgraph==3.4.1 oemthermostat==1.1.1 omnilogic==0.4.2 onkyo-eiscp==1.2.7 onvif-zeep-async==1.0.0 open-garage==0.1.4 openerz-api==0.1.0 openevsewifi==1.1.0 openhomedevice==0.7.2 opensensemap-api==0.1.5 openwebifpy==3.1.1 openwrt-luci-rpc==1.1.6 oru==0.1.11 orvibo==1.1.1 ovoenergy==1.1.7 oyaml==1.0 packaging==20.4 paho-mqtt==1.5.1 panacotta==0.1 panasonic-viera==0.3.6 pandas==1.1.4 paramiko==2.7.2 passlib==1.7.4 pathlib==1.0.1 pathtools==0.1.2 pbr==5.5.1 pcal9535a==0.7 pdunehd==1.3.2 pencompy==0.0.3 pexpect==4.6.0 pi1wire==0.1.0 pi4ioe5v9xxxx==0.0.2 pifacecommon==4.2.2 pifacedigitalio==3.0.5 piglow==1.2.4 pilight==0.1.1 Pillow==7.2.0 pizzapi==0.0.3 PlexAPI==4.2.0 plexauth==0.0.6 plexwebsocket==0.0.12 pluggy==0.13.1 Plugwise-Smile==1.6.0 plumbum==1.6.9 plumlightpad==0.0.11 ply==3.11 pmsensor==0.4 pocketcasts==0.1 poolsense==0.0.8 pprintpp==0.4.0 praw==7.1.0 prawcore==1.5.0 prayer-times-calculator==0.0.3 prettytable==2.0.0 ProgettiHWSW==0.1.1 proliphix==0.4.1 prometheus-client==0.7.1 proto-plus==1.11.0 protobuf==3.14.0 proxmoxer==1.1.1 psutil==5.7.2 psycopg2==2.8.6 ptvsd==4.3.2 ptyprocess==0.6.0 pubnub==4.7.0 pubnubsub-handler==1.0.8 pulsectl==20.2.4 pure-pcapy3==1.0.1 pure-python-adb==0.3.0.dev0 pushbullet.py==0.11.0 pushover-complete==1.1.1 pwmled==1.6.7 py==1.9.0 py-august==0.25.0 py-canary==0.5.0 py-cpuinfo==7.0.0 py-melissa-climate==2.1.4 py-nextbusnext==0.1.4 py-nightscout==1.2.2 py-schluter==0.1.7 py-synology==0.2.0 py-vapid==1.7.1 py-zabbix==1.1.7 py17track==2.2.2 pyads==3.2.2 pyaehw4a1==0.3.9 pyaftership==0.1.2 pyairvisual==5.0.4 pyalmond==0.0.2 pyarlo==0.2.3 pyasn1==0.4.8 pyasn1-modules==0.2.8 pyatag==0.3.4.4 pyatmo==4.2.0 pyAtome==0.1.1 pyatv==0.3.13 pybbox==0.0.5a0 pyblackbird==0.5 PyBluez==0.22 pybotvac==0.0.17 pycares==3.1.1 pycarwings2==2.9 pyCEC==0.4.14 pycfdns==1.2.1 pychannels==1.0.0 PyChromecast==7.5.1 pycmus==0.1.1 pycocotools==2.0.1 pycognito==0.1.4 pycomfoconnect==0.3 pyControl4==0.0.6 pycoolmasternet-async==0.1.2 pycountry==19.8.18 pycountry-convert==0.7.2 pycparser==2.20 pycryptodome==3.9.9 pycryptodomex==3.9.9 pycsspeechtts==1.0.4 pydaikin==2.3.1 pydanfossair==0.1.0 pydantic==1.7.2 pydeconz==73 pydelijn==0.6.1 pydexcom==0.2.0 PyDispatcher==2.0.5 pydoods==1.0.2 pydroid-ipcam==0.8 pyebox==1.1.4 pyeconet==0.0.11 pyedimax==0.2.1 pyEight==0.1.5 pyEmby==1.7 pyenvisalink==4.0 pyephember==0.3.1 PyEssent==0.13 pyeverlights==0.1.0 pyfido==2.1.1 pyflexit==0.3 pyflic-homeassistant==0.4.dev0 PyFlick==0.0.2 PyFlume==0.5.5 pyflunearyou==1.0.7 pyfnip==0.2 pyforked-daapd==0.1.11 pyfritzhome==0.4.2 PyFronius==0.4.6 pyftdi==0.52.0 pyfttt==0.3 PyFunctional==1.3.0 pygatt==4.0.5 PyGithub==1.43.8 Pygments==2.7.2 pygtfs==0.1.5 pygti==0.9.2 pyhaversion==3.4.2 pyheos==0.6.0 pyHik==0.2.8 pyhiveapi==0.2.20.2 pyhomematic==0.1.70 pyhomeworks==0.0.6 pyHS100==0.3.5.1 pyicloud==0.9.7 pyinsteon==1.0.8 pyintesishome==1.7.5 pyipma==2.0.5 pyipp==0.11.0 pyiqvia==0.2.1 pyirishrail==0.0.2 pyiss==1.0.1 pyisy==2.1.0 pyitachip2ir==0.0.7 pyjsparser==2.7.1 PyJWT==1.7.1 pykira==0.1.1 pykodi==0.2.1 pykwb==0.0.8 pylacrosse==0.4 pylast==3.3.0 pylaunches==1.0.0 pylgnetcast-homeassistant==0.2.0.dev0 pylibrespot-java==0.1.0 pylint==2.6.0 pylitejet==0.1.0 pyloopenergy==0.2.1 pylutron==0.2.5 pylutron-caseta==0.7.2 pymailgunner==1.4 PyMata==2.20 pymata-express==1.19 pymediaroom==0.6.4.1 PyMeeus==0.3.7 pymelcloud==2.5.2 PyMetno==0.8.1 pymfy==0.9.1 pymitv==1.4.3 pymochad==0.2.0 pymodbus==2.3.0 pymonoprice==0.3 pymsteams==0.1.12 pymusiccast==0.1.6 PyMVGLive==1.1.4 pymyq==2.0.8 pymysensors==0.18.0 PyNaCl==1.3.0 pynanoleaf==0.0.5 pynello==2.0.3 pynetgear==0.6.1 pynetio==0.1.9.1 pynuki==1.3.8 pynut2==2.1.2 pynws==1.3.0 pynx584==0.5 pynzbgetapi==0.2.0 pyobihai==1.2.3 pyodbc==4.0.30 pyombi==0.1.10 pyOpenSSL==19.1.0 pyopenuv==1.0.9 pyopnsense==0.2.0 pyoppleio==1.0.5 PyOTA==2.0.5 pyotgw==0.6b1 pyotp==2.3.0 pyowm==3.1.0 pyownet==0.10.0.post1 pyparsing==2.4.7 pypca==0.0.7 pypck==0.7.4 pypjlink2==1.2.1 pypoint==2.0.0 pyprof2calltree==1.4.5 pyps4-2ndscreen==1.1.1 Pypubsub==4.0.3 PyQRCode==1.2.1 pyqvrpro==0.52 pyqwikswitch==0.93 pyrail==0.0.3 pyrainbird==0.4.2 Pyrebase4==4.4.1 pyrecswitch==1.0.2 pyrepetier==3.0.5 pyRFC3339==1.1 pyRFXtrx==0.26.0 pyrisco==0.3.1 PyRMVtransport==0.2.9 pyruckus==0.12 pysabnzbd==1.1.0 pysaj==0.0.16 pySDCP==1 pysensibo==1.0.3 pyserial==3.4 pyserial-asyncio==0.4 pysesame2==1.0.1 pysha3==1.0.2 Pysher==1.0.1 pysignalclirestapi==0.3.4 pyskyqhub==0.1.3 pysma==0.3.5 pysmappee==0.2.13 pysmartapp==0.3.2 pysmartthings==0.7.4 pysmarty==0.8 pysmb==1.2.5 pysmi==0.3.4 pysml==0.0.2 pysnmp==4.4.12 PySocks==1.7.1 pysoma==0.0.10 pysonos==0.0.36 pyspcwebgw==0.4.0 pysqueezebox==0.5.5 pystiebeleltron==0.0.1.dev2 pysuez==0.1.19 PySyncThru==0.7.0 pytankerkoenig==0.0.6 pytautulli==0.5.0 pytest==6.1.2 pytest-cov==2.10.1 pytest-mock==3.3.1 pytest-rerunfailures==9.1.1 pytest-runner==5.2 pytfiac==0.4 pythinkingcleaner==0.0.3 python-awair==0.1.1 python-blockchain-api==0.0.2 python-clementine-remote==1.0.1 python-dateutil==2.8.1 python-didl-lite==1.2.4 python-digitalocean==1.13.2 python-ecobee-api==0.2.7 python-engineio==3.13.2 python-etherscan-api==0.0.3 python-family-hub-local==0.0.2 python-forecastio==1.4.0 python-gc100==1.0.3a0 python-gitlab==1.6.0 python-hpilo==4.3 python-http-client==3.3.1 python-izone==1.1.2 python-join-api==0.0.6 python-jose==3.2.0 python-juicenet==1.0.1 python-jwt==2.0.1 python-magic==0.4.18 python-miio==0.5.3 python-mimeparse==1.6.0 python-mpd2==1.0.0 python-mystrom==1.1.2 python-nest==4.1.0 python-nmap==0.6.1 python-opendata-transport==0.2.1 python-openzwave-mqtt==1.3.2 python-qbittorrent==0.4.1 python-ripple-api==0.0.3 python-singleton==0.1.2 python-slugify==4.0.1 python-sochain-api==0.0.2 python-socketio==4.6.0 python-songpal==0.12 python-synology==1.0.0 python-tado==0.8.1 python-telegram-bot==11.1.0 python-telnet-vlc==1.0.4 python-twitch-client==0.6.0 python-velbus==2.1.1 python-vlc==1.1.2 python-whois==0.7.3 python-wink==1.10.5 pythonegardia==1.0.40 pyTibber==0.16.0 pytile==4.0.0 pytouchline==0.7 pytraccar==0.9.0 pytrackr==0.0.5 pytradfri==7.0.4 pytrafikverket==0.1.6.2 PyTransportNSW==0.1.1 PyTurboJPEG==1.4.0 pytz==2020.4 pyubee==0.10 pyuptimerobot==0.0.5 pyusb==1.0.0b1 pyvera==0.3.11 pyversasense==0.0.6 pyvesync==1.2.0 PyViCare==0.2.0 pyvizio==0.1.57 pyvlx==0.2.18 pyvolumio==0.1.3 pyW215==0.7.0 pyW800rf32==0.1 pywebpush==1.9.2 pywemo==0.5.2 pywilight==0.0.65 pyxeoma==1.4.1 PyXiaomiGateway==0.13.4 PyYAML==5.3.1 pyzbar==0.1.7 pyzerproc==0.2.5 qnapstats==0.3.0 quantum-gateway==0.0.5 queueman==0.5 RachioPy==1.0.3 radiotherm==2.0.0 raincloudy==0.0.7 raspyrfm-client==1.2.8 ratelimit==2.2.1 readlike==0.1.2 regenmaschine==3.0.0 regex==2020.11.13 ReParser==1.4.3 repoze.lru==0.7 requests==2.25.0 requests-async==0.6.2 requests-cache==0.5.2 requests-file==1.5.1 requests-futures==1.0.0 requests-oauth==0.4.1 requests-oauthlib==1.3.0 requests-toolbelt==0.9.1 responses==0.12.1 RestrictedPython==5.0 rfc3986==1.4.0 rfk101py==0.0.1 rflink==0.0.54 ring-doorbell==0.6.0 ritassist==0.9.2 rjpl==0.3.6 rocketchat-API==0.6.1 rokuecp==0.6.0 roombapy==1.6.1 roonapi==0.0.25 rova==0.1.0 rsa==4.6 RtmAPI==0.7.2 ruamel.yaml==0.15.100 russound==0.1.9 russound-rio==0.1.7 Rx==3.1.1 rxv==0.6.0 s3transfer==0.2.1 saltbox==0.1.3 samsungctl==0.7.1 samsungtvws==1.4.0 satel-integra==0.3.4 schiene==0.23 scsgate==0.1.0 SecretStorage==3.2.0 semantic-version==2.8.5 semver==2.13.0 sendgrid==6.4.6 sense-energy==0.8.1 sense-hat==2.2.0 sentry-sdk==0.19.2 sepaxml==2.0.0 sgmllib3k==1.0.0 sharkiqpy==0.1.8 sharp-aquos-rc==0.3.2 shodan==1.24.0 simplehound==0.3 simplejson==3.17.2 simplepush==1.1.4 simplisafe-python==9.6.0 sisyphus-control==3.0 six==1.15.0 skybellpy==0.6.1 slackclient==2.5.0 sleekxmppfs==1.3.4 sleepyq==0.7 slixmpp==1.5.2 smart-meter-texas==0.4.0 SmartHab==0.21 smbus-cffi==0.5.1 smbus2==0.3.0 smhi-pkg==1.0.13 sn3218==1.2.7 snapcast==2.1.1 sniffio==1.2.0 snitun==0.20 snowballstemmer==2.0.0 socialbladeclient==0.5 solaredge==0.0.2 solaredge-local==0.2.0 solax==0.2.4 somecomfort==0.5.2 somfy-mylink-synergy==1.0.6 sonarr==0.3.0 soupsieve==2.0.1 speak2mary==1.4.0 speedtest-cli==2.1.2 Sphinx==3.3.1 sphinxcontrib-applehelp==1.0.2 sphinxcontrib-devhelp==1.0.2 sphinxcontrib-htmlhelp==1.0.3 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.4 spiderpy==1.3.1 spidev==3.5 spotcrime==1.0.4 spotify-token==1.0.0 spotipy==2.16.1 SQLAlchemy==1.3.20 srptools==1.0.1 sseclient-py==1.7 starkbank-ecdsa==1.1.0 starline==0.1.3 starlingbank==3.2 statsd==3.2.1 steamodd==4.21 stevedore==3.2.2 stookalert==0.1.4 streamlabswater==1.0.1 stringcase==1.2.0 sucks==0.9.4 sunwatcher==0.2.1 surepy==0.2.6 swisshydrodata==0.0.3 synology-srm==0.2.0 tabulate==0.8.7 tahoma-api==0.0.16 tank-utility==1.4.0 tapsaff==0.2.1 tellcore-net==0.4 tellcore-py==1.1.2 tellduslive==0.10.11 tellsticknet==0.1.2 temescal==0.3 temperusb==1.5.3 tenacity==6.2.0 tesla-powerwall==0.3.3 teslajsonpy==0.10.4 testtools==2.4.0 text-unidecode==1.3 thermoworks-smoke==0.1.8 thingspeak==1.0.0 tikteck==0.4 tmb==0.0.4 todoist-python==8.0.0 toml==0.10.2 toonapi==0.2.0 total-connect-client==0.55 tp-connected==0.0.4 tqdm==4.52.0 traceback2==1.4.0 transitions==0.8.5 transmissionrpc==0.11 TravisPy==0.3.5 tuyaha==0.0.8 twentemilieu==0.3.0 twilio==6.32.0 TwitterAPI==2.5.13 typing-extensions==3.7.4.3 typing-inspect==0.6.0 tzlocal==2.1 uamqp==1.2.12 uEagle==0.0.2 ujson==1.35 unifiled==0.11 unittest2==1.1.0 untangle==1.1.1 upb-lib==0.4.11 upcloud-api==0.4.5 update-checker==0.18.0 uplink==0.9.2 uplink-protobuf==0.1.0 uritemplate==3.0.1 url-normalize==1.4.1 urllib3==1.26.2 urwid==1.3.1 uscisstatus==0.1.1 uvcclient==0.11.0 vallox-websocket-api==2.4.0 venstarcolortouch==0.12 vilfo-api-client==0.3.2 vincenty==0.1.4 vobject==0.9.6.1 vol==0.1.1 volkszaehler==0.1.3 voluptuous==0.12.0 voluptuous-serialize==2.4.0 volvooncall==0.8.12 vsure==1.5.4 vtjp==0.1.14 vultr==0.1.2 wakeonlan==1.1.6 waqiasync==1.0.0 watchdog==0.8.3 waterfurnace==1.1.0 WazeRouteCalculator==0.12 wcwidth==0.2.5 webexteamssdk==1.1.1 websocket-client==0.54.0 websockets==8.1 Werkzeug==1.0.1 wiffi==1.0.1 wirelesstagpy==0.4.1 withings-api==2.1.6 wled==0.4.4 wolf-smartset==0.1.8 wrapt==1.12.1 WSDiscovery==2.0.0 XBee==2.3.2 xbee-helper==0.0.7 xbox-webapi==2.0.8 xboxapi==2.0.1 xfinity-gateway==0.0.4 xknx==0.15.3 XlsxWriter==1.3.7 xmltodict==0.12.0 xs1-api-client==3.0.0 yalesmartalarmclient==0.1.6 yarl==1.4.2 yeelight==0.5.4 yeelightsunflower==0.0.10 YesssSMS==0.4.1 youtube-dl==2020.11.1.1 zeep==4.0.0 zengge==0.2 zeroconf==0.28.6 zha-quirks==0.0.46 zhong-hong-hvac==1.0.9 ziggo-mediabox-xl==1.1.0 zigpy==0.27.0 zigpy-cc==0.5.2 zigpy-deconz==0.11.0 zigpy-xbee==0.13.0 zigpy-zigate==0.7.2 zigpy-znp==0.2.2 zipp==3.4.0 zm-py==0.4.0 zope.interface==5.2.0 ```
ludeeus commented 3 years ago

What OS is running on the host, and is that 32 or 64 bit?

cat /etc/os-release
uname -a
balloob commented 3 years ago

Can you run this to see if now has been overridden:

docker exec homeassistant python3 -c "import datetime; print(datetime.datetime.now)"

The output should be something like <built-in method now of type object at 0x92ab80> (the "at" part will differ)

sermayoral commented 3 years ago

Can you run this to see if now has been overridden:

docker exec homeassistant python3 -c "import datetime; print(datetime.datetime.now)"

The output should be something like <built-in method now of type object at 0x92ab80> (the "at" part will differ)

$ docker exec homeassistant python3 -c "import datetime; print(datetime.datetime.now)" <built-in method now of type object at 0xb6ac00d4>

sermayoral commented 3 years ago

What OS is running on the host, and is that 32 or 64 bit?

cat /etc/os-release
uname -a

32 bits both, OS and HA

$ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
$ uname -a
Linux raspberrypi4 5.4.72-v7l+ #1356 SMP Thu Oct 22 13:57:51 BST 2020 armv7l GNU/Linux
pvizeli commented 3 years ago

Issue comes from: https://github.com/alpinelinux/docker-alpine/issues/117

sermayoral commented 3 years ago

Thanks @pvizeli.

This reference makes more sense, and that explains why this is working on some systems and no on others. The key was the HA architecture version. People using 64 bits architecture version doesn't have this issue, and people using 32 bits version does.

@balloob this is probably the base problem in https://github.com/home-assistant/core/issues/43337 as well

rt400 commented 3 years ago

i fix the problem by remove environment : TZ , and add volume

@sermayoral i used with 64-bit and have the same problem

sermayoral commented 3 years ago

Thank you guys 😊

sermayoral commented 3 years ago

I can confirm it's working again :-)