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

Error with binary_sensor.ble_motion in 7.8.2 #739

Closed
Kaibob2 opened this issue Feb 22, 2022 · 11 comments
Closed

Error with binary_sensor.ble_motion in 7.8.2 #739

Kaibob2 opened this issue Feb 22, 2022 · 11 comments
Labels
bug Something isn't working fixed in beta This issue is fixed in the current beta release

Comments

@Kaibob2
Copy link

Kaibob2 commented Feb 22, 2022

With Version 7.8.2 I get the following error for both MJYD02YL in my home.
Is there something I'm missing?

2022-02-22 17:36:21 ERROR (MainThread) [homeassistant.helpers.entity] Update for binary_sensor.ble_motion_bewegungsmelder_flur fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 521, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 725, in async_device_update
raise exc
File "/config/custom_components/ble_monitor/binary_sensor.py", line 470, in async_update
if now - self._start_timer >= timedelta(seconds=self._reset_timer):
TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'str'
@Ernst79
Copy link
Collaborator

Ernst79 commented Feb 22, 2022

Did you get this message multiple times (for one sensor), or only once?

The 7.8.2 update could cause this error, but I think it will only happen once. So, if it doesn't happen again, you can just ignore it.

@Kaibob2
Copy link
Author

Kaibob2 commented Feb 22, 2022

I first thought, it happens each time the sensor detects any motion, but it appears, that it only happens 4 times
It's three hours later now with dozens correctly detected motions events but no more log entry.
I guess this will be ignore then :)

2022-02-22 17:33:06 ERROR (MainThread) [homeassistant.helpers.entity] Update for binary_sensor.ble_motion_bewegungsmelder_bad fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 521, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 725, in async_device_update
raise exc
File "/config/custom_components/ble_monitor/binary_sensor.py", line 470, in async_update
if now - self._start_timer >= timedelta(seconds=self._reset_timer):
TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'str'
2022-02-22 17:33:21 ERROR (MainThread) [homeassistant.helpers.entity] Update for binary_sensor.ble_motion_bewegungsmelder_flur fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 521, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 725, in async_device_update
raise exc
File "/config/custom_components/ble_monitor/binary_sensor.py", line 470, in async_update
if now - self._start_timer >= timedelta(seconds=self._reset_timer):
TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'str'
2022-02-22 17:36:21 ERROR (MainThread) [homeassistant.helpers.entity] Update for binary_sensor.ble_motion_bewegungsmelder_flur fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 521, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 725, in async_device_update
raise exc
File "/config/custom_components/ble_monitor/binary_sensor.py", line 470, in async_update
if now - self._start_timer >= timedelta(seconds=self._reset_timer):
TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'str'
2022-02-22 17:41:21 ERROR (MainThread) [homeassistant.helpers.entity] Update for binary_sensor.ble_motion_bewegungsmelder_flur fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 521, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 725, in async_device_update
raise exc
File "/config/custom_components/ble_monitor/binary_sensor.py", line 470, in async_update
if now - self._start_timer >= timedelta(seconds=self._reset_timer):
TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'str'

@Ernst79
Copy link
Collaborator

Ernst79 commented Feb 22, 2022

For now, I close the issue, but if it happens again, let me know, by reopening this issue.

@Ernst79 Ernst79 closed this as completed Feb 22, 2022
@ACrazyConcept
Copy link

I get the same error also with MJYD02YL on version 7.9.6.
I think it happens shortly after restarting HA (in docker). Although I haven't monitored it that closely.

2022-03-12 11:40:29 ERROR (MainThread) [homeassistant.helpers.entity] Update for binary_sensor.ble_motion_28d12737b661 fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 535, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 744, in async_device_update
    raise exc
  File "/config/custom_components/ble_monitor/binary_sensor.py", line 470, in async_update
    if now - self._start_timer >= timedelta(seconds=self._reset_timer):
TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'str'

@Ernst79 Ernst79 reopened this Mar 12, 2022
@Ernst79
Copy link
Collaborator

Ernst79 commented Mar 12, 2022

Could you do me a favor. At line 475-476 in binary_sensor.py, you can find the following code

            except KeyError:
                self._state = self._newstate

Change this to

            except KeyError:
                self._state = self._newstate
            except TypeError:
                self._state = self._newstate
                _LOGGER.error("motion reset timer fails, start timer is %s", self._extra_state_attributes["last_motion"])

It should add an error in the log when it happens, but will continue to work. Please post the error here, so I can fix it.

@ACrazyConcept
Copy link

2022-03-12 15:40:21 ERROR (MainThread) [custom_components.ble_monitor.binary_sensor] motion reset timer fails, start timer is 2022-03-12T15:38:19.021859+01:00

@janikarna
Copy link

I seem to have this problem also:

Logger: homeassistant.helpers.entity
Source: custom_components/ble_monitor/binary_sensor.py:470
Integration: Passive BLE monitor (documentation, issues)
First occurred: 16.45.51 (379 occurrences)
Last logged: 17.18.09

Update for binary_sensor.ruuvitag_ulko_motion_cb2e472bead8 fails
Update for binary_sensor.ruuvitag_tyohuone_motion_fa2e97d9f02e fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 535, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 744, in async_device_update
raise exc
File "/config/custom_components/ble_monitor/binary_sensor.py", line 470, in async_update
if now - self._start_timer >= timedelta(seconds=self._reset_timer):
TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'str'

I have Home Assistant OS running on RPI4. I don't think I'll be able to edit any .py files.

@Ernst79
Copy link
Collaborator

Ernst79 commented Mar 16, 2022

I'll fix it in the next release. Somehow, the self._start_timer is stored as a string, not a datetime.datetime object.

@janikarna
Copy link

Ok, thank you for the information. the sensor does work as expected and the errors are not piling up for a while if I go and move the sensors a bit. But mine is for temp/humidity measurements and stationary, so motion is not needed :)

@Ernst79
Copy link
Collaborator

Ernst79 commented Mar 17, 2022

Please try with 8.0.5-beta. Should be solved in that version

@Ernst79 Ernst79 added bug Something isn't working fixed in beta This issue is fixed in the current beta release labels Mar 17, 2022
@Ernst79
Copy link
Collaborator

Ernst79 commented Mar 18, 2022

Should be fixed in 8.1.0, which has just been released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in beta This issue is fixed in the current beta release
Projects
None yet
Development

No branches or pull requests

4 participants