vinteo / hass-opensprinkler

OpenSprinkler Integration for Home Assistant
MIT License
211 stars 40 forks source link

Year 13592 is out of range #220

Closed whodat closed 9 months ago

whodat commented 1 year ago

Getting the following error when trying to run sprinklers from Home Assistant. "Failed to call service opensprinkler/run. year 13592 is out of range"

Home Assistant: 2023.6.3 hass-opensprinkler: 1.1.15 OpenSprinkler firmware: 2.2.0 (2)

2023-07-03 22:59:41.350 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 229, in _handle_refresh_interval await self._async_refresh(log_failures=True, scheduled=True) File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 374, in _async_refresh self.async_update_listeners() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 164, in async_update_listeners update_callback() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 590, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 654, in _async_write_ha_state state = self._stringify_state(available) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 596, in _stringify_state if (state := self.state) is None: ^^^^^^^^^^ File "/config/custom_components/opensprinkler/__init__.py", line 224, in state return self._get_state() ^^^^^^^^^^^^^^^^^ File "/config/custom_components/opensprinkler/sensor.py", line 237, in _get_state return utc_from_timestamp(rdst).isoformat() ^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: year 13592 is out of range

vinteo commented 1 year ago

What parameters are you sending to the run service? Can you show your config?

whodat commented 1 year ago

Which config file? I'm just using opensprinkler-card, and haven't customized anything.

image

vinteo commented 1 year ago

I haven't been using that card, will try look into it when if I get time. In the meantime you could try see if they can help you at the GitHub for the card .

On Tue, Jul 4, 2023, 2:16 PM whodat @.***> wrote:

Which config file? I'm just using opensprinkler-card, and haven't customized anything.

  • type: custom:opensprinkler-card device: 77689a0238e392207b51cc8be7feaa18 name: Sprinkler

[image: image] https://user-images.githubusercontent.com/1149466/250745326-32b73a90-eccb-4c8f-a3ec-b080caf67e94.png

— Reply to this email directly, view it on GitHub https://github.com/vinteo/hass-opensprinkler/issues/220#issuecomment-1619451869, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGID7ZDHEUQDHM44JXSWMLXOOKIRANCNFSM6AAAAAAZ5D6T2U . You are receiving this because you commented.Message ID: @.***>

whodat commented 1 year ago

Okay, I decided to get the card out of the equation, so removed it completely from my dashboard and deleted it's folder in Home-Assistant\www\opensprinkler-card, and restarted Home Assistant.

I then called the service manually using Developer Tools, and it shows an error there as well. Although it DOES still start the sprinkler. But it did when using the card as well. I am still seeing the "Year 13592 is out of range" errors in the log, they appear there continuously as soon as Home Assistant is started, without me even calling the service.

image

image

image

vinteo commented 1 year ago

What are you running home assistant on and what version is your python?

On Tue, Jul 4, 2023, 5:21 PM whodat @.***> wrote:

Okay, I decided to get the card out of the equation, so removed it completely from my dashboard and deleted it's folder in Home-Assistant\www\opensprinkler-card, and restarted Home Assistant.

I then called the service manually using Developer Tools, and it shows an error there as well. Although it DOES still start the sprinkler. But it did when using the card as well. I am still seeing the "Year 13592 is out of range" errors in the log, they appear there continuously as soon as Home Assistant is started, without me even calling the service.

[image: image] https://user-images.githubusercontent.com/1149466/250796540-0b24fa18-db35-4bbc-be43-526dac045e56.png

[image: image] https://user-images.githubusercontent.com/1149466/250796681-dc238ce6-2f4c-4d28-b6c2-aaf0c96a22aa.png

[image: image] https://user-images.githubusercontent.com/1149466/250796741-ccead411-7546-4a47-9a66-d1ed3fd7b034.png

— Reply to this email directly, view it on GitHub https://github.com/vinteo/hass-opensprinkler/issues/220#issuecomment-1619660872, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGID7YSMSV7X54IVPBCSKTXOO76NANCNFSM6AAAAAAZ5D6T2U . You are receiving this because you commented.Message ID: @.***>

whodat commented 1 year ago

Running home assistant as a docker container on Unraid. Running this docker (latest version) : https://registry.hub.docker.com/r/homeassistant/home-assistant/ Python in the docker container is 3.11.4

image

whodat commented 1 year ago

I logged the rdst value, and it appears rdst is in milliseconds, and utc_from_timestamp() expects seconds? I changed the function to divide by 1000, and the error went away...

` def _get_state(self): """Retrieve latest state.""" rdst = self._controller.rain_delay_stop_time if rdst == 0: return None

    _LOGGER.info('rdst value: %s', rdst)

    return utc_from_timestamp(rdst/1000).isoformat()

`

image

vinteo commented 1 year ago

Had a quick look and you are right, but all other timestamps are in seconds except the rain delay stop time. Not sure if 2.2.0 firmware changed this but I think it was working before. Just another one of those inconsistencies with the OS API ... lol.

I think I have to "fix" it on the pyopensprinkler library, the timestamp itself is wrong I believe because of this millisecond/second issue.

vinteo commented 1 year ago

It looks like they will fix it on the firmware side so I probably will not do anything on this end:

https://github.com/OpenSprinkler/OpenSprinkler-Firmware/issues/233

whodat commented 1 year ago

sounds good, thanks!

vinteo commented 9 months ago

@whodat looks like the fix was released in 2.2.0 (3)