home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.8k stars 30.9k forks source link

La Marzocco integration generating KeyError for dose_k5 on GS/3 AV #109567

Closed rccoleman closed 9 months ago

rccoleman commented 9 months ago

The problem

After configuring the new core La Marzocco integration, I'm seeing this repeatedly in the log:

2024-02-03 16:34:45.951 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 256, in _handle_refresh_interval
    await self._async_refresh(log_failures=True, scheduled=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 412, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 183, in async_update_listeners
    update_callback()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 492, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 989, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1110, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1047, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 995, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/number/__init__.py", line 351, in state
    return self.value
           ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/number/__init__.py", line 390, in value
    if (native_value := self.native_value) is None:
                        ^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/lamarzocco/number.py", line 115, in native_value
    return self.entity_description.native_value_fn(self.coordinator.lm)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/lamarzocco/number.py", line 82, in <lambda>
    native_value_fn=lambda lm: lm.current_status["dose_k5"],
                               ~~~~~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: 'dose_k5'

I believe that "key 5" used to correspond to the "continuous" button and allowed a pulse count to be specified (defaulted to 1000 == 500mL), but that was dropped in the transition to the new interface. If I remove the code that looks for dose_k5, the error goes away.

What version of Home Assistant Core has the issue?

core-2024.2.0b4

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

La Marzocco

Link to integration documentation on our website

https://rc.home-assistant.io/integrations/lamarzocco

Diagnostics information

config_entry-lamarzocco-7e2f3bdf32809201956feca41b4ff34d.json

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

There are a few other things in the integration that I hope are on the roadmap, like:

image

And a re-enabling of the attributes that we had with the previous custom integration (or maybe a service call that returns that info?). The lovelace cards that I wrote depend on that info and lack of feedback about, say, the on/off schedules that can be modified but aren't actually shown would improve the user experience.

home-assistant[bot] commented 9 months ago

Hey there @zweckj, mind taking a look at this issue as it has been labeled with an integration (lamarzocco) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `lamarzocco` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign lamarzocco` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


lamarzocco documentation lamarzocco source (message by IssueLinks)

rccoleman commented 9 months ago

Looking closer at the code, dose_k5 is interpreted as "hot water/tea". Maybe it will help to see the config from the LM website for my machine? For what it's worth, I did just update my gateway version from v3.2-rc9 to v3.3-rc7.

{
    "version": "v1",
    "preinfusionModesAvailable": [
        "ByDoseType"
    ],
    "machineCapabilities": [
        {
            "family": "GS3AV",
            "groupsNumber": 1,
            "coffeeBoilersNumber": 1,
            "hasCupWarmer": false,
            "steamBoilersNumber": 1,
            "teaDosesNumber": 1,
            "machineModes": [
                "BrewingMode",
                "StandBy"
            ],
            "schedulingType": "weeklyScheduling"
        }
    ],
    "machine_sn": "xxx",
    "machine_hw": "2",
    "isPlumbedIn": true,
    "isBackFlushEnabled": false,
    "standByTime": 0,
    "tankStatus": true,
    "groupCapabilities": [
        {
            "capabilities": {
                "groupType": "AV_Group",
                "groupNumber": "Group1",
                "boilerId": "CoffeeBoiler1",
                "hasScale": false,
                "hasFlowmeter": true,
                "numberOfDoses": 4
            },
            "doses": [
                {
                    "groupNumber": "Group1",
                    "doseIndex": "DoseA",
                    "doseType": "PulsesType",
                    "stopTarget": 135
                },
                {
                    "groupNumber": "Group1",
                    "doseIndex": "DoseB",
                    "doseType": "PulsesType",
                    "stopTarget": 95
                },
                {
                    "groupNumber": "Group1",
                    "doseIndex": "DoseC",
                    "doseType": "PulsesType",
                    "stopTarget": 85
                },
                {
                    "groupNumber": "Group1",
                    "doseIndex": "DoseD",
                    "doseType": "PulsesType",
                    "stopTarget": 77
                }
            ],
            "doseMode": {
                "groupNumber": "Group1",
                "brewingType": "PulsesType"
            }
        }
    ],
    "machineMode": "StandBy",
    "teaDoses": {
        "DoseA": {
            "doseIndex": "DoseA",
            "stopTarget": 8
        }
    },
    "boilers": [
        {
            "id": "SteamBoiler",
            "isEnabled": false,
            "target": 123.90000152587891,
            "current": 27.600000381469727
        },
        {
            "id": "CoffeeBoiler1",
            "isEnabled": true,
            "target": 93.3000030517578,
            "current": 28.600000381469727
        }
    ],
    "boilerTargetTemperature": {
        "SteamBoiler": 123.90000152587891,
        "CoffeeBoiler1": 93.3000030517578
    },
    "preinfusionMode": {
        "Group1": {
            "groupNumber": "Group1",
            "preinfusionStyle": "PreinfusionByDoseType"
        }
    },
    "preinfusionSettings": {
        "mode": "TypeB",
        "Group1": [
            {
                "groupNumber": "Group1",
                "doseType": "DoseA",
                "preWetTime": 0,
                "preWetHoldTime": 4
            },
            {
                "groupNumber": "Group1",
                "doseType": "DoseB",
                "preWetTime": 0,
                "preWetHoldTime": 4
            },
            {
                "groupNumber": "Group1",
                "doseType": "DoseC",
                "preWetTime": 0,
                "preWetHoldTime": 4
            },
            {
                "groupNumber": "Group1",
                "doseType": "DoseD",
                "preWetTime": 0,
                "preWetHoldTime": 4
            }
        ]
    },
    "weeklySchedulingConfig": {
        "enabled": true,
        "monday": {
            "enabled": true,
            "h_on": 6,
            "h_off": 16,
            "m_on": 0,
            "m_off": 0
        },
        "tuesday": {
            "enabled": true,
            "h_on": 6,
            "h_off": 16,
            "m_on": 0,
            "m_off": 0
        },
        "wednesday": {
            "enabled": true,
            "h_on": 6,
            "h_off": 16,
            "m_on": 0,
            "m_off": 0
        },
        "thursday": {
            "enabled": true,
            "h_on": 6,
            "h_off": 16,
            "m_on": 0,
            "m_off": 0
        },
        "friday": {
            "enabled": true,
            "h_on": 6,
            "h_off": 16,
            "m_on": 0,
            "m_off": 0
        },
        "saturday": {
            "enabled": true,
            "h_on": 6,
            "h_off": 16,
            "m_on": 0,
            "m_off": 0
        },
        "sunday": {
            "enabled": true,
            "h_on": 6,
            "h_off": 16,
            "m_on": 0,
            "m_off": 0
        }
    },
    "clock": "1901-02-04T16:39:00",
    "firmwareVersions": [
        {
            "name": "machine_firmware",
            "fw_version": "1.48"
        },
        {
            "name": "gateway_firmware",
            "fw_version": "v3.3-rc7"
        }
    ]
}
zweckj commented 9 months ago

Thanks. Set in incorrect in my tests, and wrongly modelled accordingly...

Regarding the extra_attributes those (probably) won't return. I still have open PRs (https://github.com/home-assistant/core/pull/108258, https://github.com/home-assistant/core/pull/108245, https://github.com/home-assistant/core/pull/108237) which will allow configuring and displaying doses and pre-infusion/-brew per key, display the schedule as HA calendar, and services to configure it.