marcelwestrahome / home-assistant-niu-component

niu scooter integration for Home assistant.
Apache License 2.0
47 stars 30 forks source link

Location not updated / everything else does... #60

Closed Verguldebarman closed 2 weeks ago

Verguldebarman commented 2 weeks ago

My NIU integration works perfectly, with one exception; location is not updated and always remains with the same GPS coordinates (in Latitude, Longitude and Scooterconnected sensors). Everything else works!

Also Last Tracks works, so GPS is working correctly (obviously deleted some locations ;-)): image

I have set the custom component to debug in configuration:

logger:
  default: error
  logs:
    custom_components.niu: debug

The only errors I see are these:

2024-11-04 12:00:57.756 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.niu_scooter_scooter_lasttrackridingtime fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 942, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1300, in async_device_update
    await self.async_update()
  File "/config/custom_components/niu/sensor.py", line 163, in async_update
    self._state = self._api.getDataTrack(self._id_name)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/niu/api.py", line 163, in getDataTrack
    return strftime("%H:%M:%S", gmtime(self.dataTrackInfo["data"][0][id_field]))
                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
KeyError: 0
2024-11-04 12:04:27.677 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.niu_scooter_scooter_lasttrackdistance fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 942, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1300, in async_device_update
    await self.async_update()
  File "/config/custom_components/niu/sensor.py", line 163, in async_update
    self._state = self._api.getDataTrack(self._id_name)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/niu/api.py", line 169, in getDataTrack
    return self.dataTrackInfo["data"][0][id_field]
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
KeyError: 0
2024-11-04 12:04:27.684 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.niu_scooter_scooter_lasttrackendtime fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 942, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1300, in async_device_update
    await self.async_update()
  File "/config/custom_components/niu/sensor.py", line 163, in async_update
    self._state = self._api.getDataTrack(self._id_name)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/niu/api.py", line 160, in getDataTrack
    (self.dataTrackInfo["data"][0][id_field]) / 1000
     ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
KeyError: 0
2024-11-04 12:27:27.750 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.niu_scooter_scooter_lasttrackdistance fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 942, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1300, in async_device_update
    await self.async_update()
  File "/config/custom_components/niu/sensor.py", line 163, in async_update
    self._state = self._api.getDataTrack(self._id_name)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/niu/api.py", line 169, in getDataTrack
    return self.dataTrackInfo["data"][0][id_field]
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
KeyError: 0
2024-11-04 13:12:57.956 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.niu_scooter_scooter_lasttrackstarttime fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 942, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1300, in async_device_update
    await self.async_update()
  File "/config/custom_components/niu/sensor.py", line 163, in async_update
    self._state = self._api.getDataTrack(self._id_name)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/niu/api.py", line 160, in getDataTrack
    (self.dataTrackInfo["data"][0][id_field]) / 1000
     ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
KeyError: 0
2024-11-04 13:12:57.992 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.niu_scooter_scooter_lasttrackendtime fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 942, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1300, in async_device_update
    await self.async_update()
  File "/config/custom_components/niu/sensor.py", line 163, in async_update
    self._state = self._api.getDataTrack(self._id_name)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/niu/api.py", line 160, in getDataTrack
    (self.dataTrackInfo["data"][0][id_field]) / 1000
     ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
KeyError: 0

These seem not to be related to location.

Any thoughts?

marcelwestrahome commented 2 weeks ago

mm, was just checking my scooters and it works with both. See also my other message, I have a new job and nearly time to solve this :-(

Verguldebarman commented 2 weeks ago

I have toggled "GPS enabled" in the NIU app and now it works again. Can be closed and for future reference.