Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Companion's Next Alarm sensor doesnt restore its state after Core restart #77106

Closed
chertvl opened this issue Aug 21, 2022 · 6 comments
Closed

Comments

@chertvl
Copy link

chertvl commented Aug 21, 2022

The problem

Seems like after PR #76886 I get new bug by using Core 2022.8.6.
Next Alarm sensor of Android HA Companion doesn't restore its state after HA Core restart and becomes 'unavailable' with this error in log:

image

I tried several Companion versions (include last beta) and several Alarm app packages from GPlay.
Everytime after HA restart I need to toggle alarm in my phone, then sensor.*_next_alarm will show datetime and will work for all next alarms.
Now It difficult to use this sensor for automations, because it 'unavailable' till state is change (missing first potential 'fire' of automation after Core restart).

Next Alarm sensor with HA Core 2022.8.5 works perfectly.

Previously I described issue here:
home-assistant/android#2811
but seems its not a companion's problem.

What version of Home Assistant Core has the issue?

2022.8.6

What was the last working version of Home Assistant Core?

2022.8.5

What type of installation are you running?

Home Assistant OS

Integration causing the issue

sensor, mobile_app

@probot-home-assistant
Copy link

mobile_app documentation
mobile_app source
(message by IssueLinks)

@probot-home-assistant
Copy link

Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (mobile_app) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@chertvl
Copy link
Author

chertvl commented Aug 25, 2022

@frenck @balloob @emontnemery
Could you please take a look at this?

@MountainGod2
Copy link

Same issue here.

Logger: homeassistant.components.sensor
Source: util/dt.py:185
Integration: Sensor (documentation, issues)
First occurred: 5:39:00 PM (2 occurrences)
Last logged: 5:39:00 PM

Error adding entities for domain sensor with platform mobile_app
Error while setting up mobile_app platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 428, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 673, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 776, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 532, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 570, in _async_write_ha_state
    state = self._stringify_state(available)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 538, in _stringify_state
    if (state := self.state) is None:
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 388, in state
    value = self.native_value
  File "/usr/src/homeassistant/homeassistant/components/mobile_app/sensor.py", line 113, in native_value
    and (timestamp := dt_util.parse_datetime(state)) is not None
  File "/usr/src/homeassistant/homeassistant/util/dt.py", line 185, in parse_datetime
    return ciso8601.parse_datetime(dt_str)
TypeError: argument 1 must be str, not datetime.datetime

sensor.pixel_6_next_alarm becomes unavailable after restarting and the attributes become:

restored: true
device_class: timestamp
icon: mdi:alarm
friendly_name: Pixel 6 Next Alarm
supported_features: 0

Until I open the alarm app and disable/enable an alarm, setting the state and bringing the attributes back to normal.

@DAVe3283
Copy link

This is also happening for me, and with the Last Reboot sensor as well. It seems that restoring a timestamp is not working for the companion app.

@chertvl
Copy link
Author

chertvl commented Sep 11, 2022

Looks like in 2022.9.2 is ok.

@chertvl chertvl closed this as completed Sep 11, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Oct 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants