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

Thermostat card not updating correctly #15483

Closed
3 tasks done
msp1974 opened this issue Feb 17, 2023 · 7 comments · Fixed by #15497
Closed
3 tasks done

Thermostat card not updating correctly #15483

msp1974 opened this issue Feb 17, 2023 · 7 comments · Fixed by #15497

Comments

@msp1974
Copy link
Contributor

msp1974 commented Feb 17, 2023

Checklist

  • I have updated to the latest available Home Assistant version.
  • I have cleared the cache of my browser.
  • I have tried a different browser to see if it is related to my browser.

Describe the issue you are experiencing

A part of a well established custom component (Wiser integration), we are trying to add a new function for heating control. This allows the temperature to be a range (min/max). However, one of the options is to tie the max to the scheduled temperature and therefore not allow it to be changed (but leave the min user selectable) via the thermostat card slider.

When the max temp is changed using the slider, the underlying custom component will not change it and leave at the pre-determined scheduled temp.

Using the thermostat card, it does not update to reflect that the temp range is not what was set by the user but maintains the temp that was set (both the slider and the text temp range).

If doing this using the more-info dialog for the thermostat card, this does work as expected. The new temp shows red while waiting to update and then reverts to the scheduled temp after a couple of seconds. The thermostat card never updates without a refresh of browser.

Describe the behavior you expected

I expect the thermostat card to revert to the actual max temp (slider and text range) as the more-info dialog box does.

Steps to reproduce the issue

Steps to recreate:

  1. Create climate mqtt template device as per below config
  2. Set initial temp state as 21C with mqtt message on topic study/ac/temp/state
  3. Using the thermostat card, change the temp to 23C (or any other value but 21C)
  4. Send mqtt message of temp state to 21C on topic study/ac/temp/state (to recreate a failed/blocked update) - thermostat card will remain at 23C
  5. Send mqtt message to set temp to any other value and card will update.

Climate Device Config Yaml

mqtt:
  climate:
    - name: Study
      modes:
        - "off"
        - "heat"
        - "auto"
      mode_command_topic: "study/ac/mode/set"
      mode_state_topic: "study/ac/mode/state"
      mode_state_template: "{{ value_json }}"
      current_temperature_topic: "study/ac/temp/current"
      temperature_state_topic: "study/ac/temp/state"
      temperature_command_topic: "study/ac/temp/set"

...

What version of Home Assistant Core has the issue?

2023.1

What was the last working version of Home Assistant Core?

NA

In which browser are you experiencing the issue with?

Firefox 109.0.1, Google Chrome Version 109.0.5414.121 (Official Build) (64-bit)

Which operating system are you using to run this browser?

Ubuntu 20.04 and Windows 11

State of relevant entities

No response

Problem-relevant frontend configuration

No response

Javascript errors shown in your browser console/inspector

No errors in browser console

Additional information

https://loom.com/share/8f47d748a0d84bfc87e9daa5b4721450

You will see this behaviour in the above video. The climate card maintains the temp set by the slider (not reverting). The more info card does revert. Even when closing the more info card, the thermostat card does not update.

@msp1974
Copy link
Contributor Author

msp1974 commented Feb 17, 2023

It seems that the more-info dialog has specific code to deal with the state not changing as a result of the service call and resync the state object after a 2 second delay if no state change event happens.

The climate card does not have this same logic which I suspect is the issue. I think the climate card needs this function adding and all action handlers call this instead of a direct service call.

From https://github.com/home-assistant/frontend/blob/master/src/dialogs/more-info/controls/more-info-climate.ts

private async _callServiceHelper(
    oldVal: unknown,
    newVal: unknown,
    service: string,
    data: {
      entity_id?: string;
      [key: string]: unknown;
    }
  ) {
    if (oldVal === newVal) {
      return;
    }

    data.entity_id = this.stateObj!.entity_id;
    const curState = this.stateObj;

    await this.hass.callService("climate", service, data);

    // We reset stateObj to re-sync the inputs with the state. It will be out
    // of sync if our service call did not result in the entity to be turned
    // on. Since the state is not changing, the resync is not called automatic.
    await new Promise((resolve) => setTimeout(resolve, 2000));

    // No need to resync if we received a new state.
    if (this.stateObj !== curState) {
      return;
    }

    this.stateObj = undefined;
    await this.updateComplete;
    // Only restore if not set yet by a state change
    if (this.stateObj === undefined) {
      this.stateObj = curState;
    }
  }

@karwosts
Copy link
Contributor

Can you confirm if this is an issue with the thermostat card, or the actual attributes of the entity are not changing? E.g. see this video below I have the climate card, the climate attributes side by side. When I change the range outside of the thermostat card, it always updates correctly. If your video clip included the actual live attributes of the entity, that would maybe help show the issue.

thermostat_range

Also, is there any way you can think of for a developer to be able to test this? Your step of "Block the max temp from being changed in entity code" is not something that sounds like it would be something easy to reproduce.

Is there maybe some kind of MQTT thermostat setup you could think of such that when you change the temperature slider it always fails to acknowledge, and would exhibit this? Just anything that would be easy for someone to plop in to test, otherwise it's difficult to understand how to reproduce this.

@msp1974
Copy link
Contributor Author

msp1974 commented Feb 17, 2023

This is definitely an issue with the thermostat card. The target_temp_high attribute does not change (which is correct in this scenario) but the card does not resync with the attribute values as none of them actually changed, leaving the card displaying the wrong values.

See my previous post, it was obviouly picked up as an issue before in the more info dialog and this should therefore be applied to the card itself.

I will think more on how to test as I see the point but in essence, async_set_temperature should do nothing to change any value which will then exhibit this behaviour.

EDIT: Adding link with side by side with attributes.

https://www.loom.com/share/1b94e25bf87c4d268c8ed7d50f353443

@msp1974
Copy link
Contributor Author

msp1974 commented Feb 18, 2023

Update: Have updated steps to recreate using a MQTT climate device.

@karwosts
Copy link
Contributor

Thanks for the additional info, that is helpful. I can see that the temperature slider does not "snap back" to the initial state when a call service fails to cause a change in the tracked entity. I'll try playing around with it and see if I can figure out how to make it work, something similar to more-info seems good. Won't make any promises yet though.

@karwosts
Copy link
Contributor

I believe #15497 will fix this.

@jbouwh
Copy link
Contributor

jbouwh commented Feb 20, 2023

Look like a dupicate of #14961

@github-actions github-actions bot locked and limited conversation to collaborators Feb 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants