core: Missing device tracker for automower with position data

The problem

I am not getting a device tracker-sensor for my automower 430X.

I was really exited for the 2024.4 version of HA because i thought it would enable me to track the mower again on a map (which worked perfectly with the HACS version of this integration) with the added device tracker functionality.

Unfortunately it seems that the integration only creates a device tracker if the husqvarna api reports the “position-capablitiy” for the mower. For my mower the husqvarna api says

"capabilities": {
      "headlights": true,
      "work_areas": false,
      "position": false,
      "stay_out_zones": false
    },

but also includes position data:

"positions": [
          {
            "latitude": 52.8,
            "longitude": 9.0
          },
          {
            "latitude": 52.8,
            "longitude": 9.0
          },
           <....>
        ],

(I’ve included the full diagnostics file and the full api /mowers response, see below)

It would be nice if a device tracker would be created even though the “capability” is false.

What version of Home Assistant Core has the issue?

core-2024.4.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Husqvarna Automower

Link to integration documentation on our website

https://www.home-assistant.io/integrations/husqvarna_automower

Diagnostics information

Diagnostic info from the integration/device: husqvarna_automower-c77abf0e3c7f68fd0e26524b70d0b3e1-Hugo-07ae1b462872a4cc3b9df109d5c5ee59.json

API reponse which a manually got from the /mowers endpoint (i shortened the long/latitudes and the position list itself): response_1712354730226.json

Example YAML snippet

No response

Anything in the logs that might be useful for us?

I dont think its related but there seems to be an issue with the timezones:

Logger: homeassistant
Quelle: util/dt.py:139
Erstmals aufgetreten: 08:01:59 (355 Vorkommnisse)
Zuletzt protokolliert: 19:51:06

Error doing job: Exception in callback AutomowerDataUpdateCoordinator.callback({'537aeba7-ec5...-34299db1e5c6': MowerAttribut...rk_areas=None), 'f480ba21-ea5...-970f64adb8cc': MowerAttribut...rk_areas=None)})
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/src/homeassistant/homeassistant/components/husqvarna_automower/coordinator.py", line 52, in callback
    self.async_set_updated_data(ws_data)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 441, in async_set_updated_data
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 168, in async_update_listeners
    update_callback()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 494, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 998, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1119, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1056, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1004, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 548, in state
    value = self.native_value
            ^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/husqvarna_automower/sensor.py", line 179, in native_value
    return self.entity_description.value_fn(self.mower_attributes)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/husqvarna_automower/sensor.py", line 142, in <lambda>
    value_fn=lambda data: dt_util.as_local(data.planner.next_start_datetime),
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/dt.py", line 139, in as_local
    if dattim.tzinfo == DEFAULT_TIME_ZONE:
       ^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'tzinfo'

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

I got the following information from Husqvarna: “We will update the code for some of the older models that have positions but not reporting true on position capability”. I close this issue, because there won’t be a change here.

With my 405X I’ve the same problem. The capability “position” is false however the capability “positions” has positions in it.