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

Aqara E1 thermostat external temperature sensor #2802

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

mb1248
Copy link

@mb1248 mb1248 commented Dec 5, 2023

Proposed change

Support for external temperature sensor.

Additional information

This is a copy of the not merged part from #2109. Discussion starts under #2687

Checklist

  • The changes are tested and work correctly
  • pre-commit checks pass / the code has been formatted using Black
  • Tests have been added to verify that the new code works

@mb1248 mb1248 force-pushed the aqara_extern_temperature branch from bc5e507 to 09ac057 Compare December 5, 2023 19:01
Copy link

codecov bot commented Dec 5, 2023

Codecov Report

Attention: Patch coverage is 24.19355% with 47 lines in your changes missing coverage. Please review.

Project coverage is 87.17%. Comparing base (04ac526) to head (7f30c58).
Report is 317 commits behind head on dev.

Files with missing lines Patch % Lines
zhaquirks/xiaomi/aqara/thermostat_agl001.py 24.19% 47 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #2802      +/-   ##
==========================================
- Coverage   87.61%   87.17%   -0.44%     
==========================================
  Files         295      295              
  Lines        9032     9094      +62     
==========================================
+ Hits         7913     7928      +15     
- Misses       1119     1166      +47     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@TheJulianJES TheJulianJES added the Xiaomi Request/PR regarding a Xiaomi device label Dec 24, 2023
@fzob
Copy link

fzob commented Jan 26, 2024

What is the status here? I could help implement or test, as I would also like to use this feature in the future :-)

@mb1248
Copy link
Author

mb1248 commented Jan 26, 2024

Hi @fzob, feel free. The new cluster appears in the ZHA device tab and I can send command to it. But if I read them they are not changed. My guess is, that the message is not correct, but I didn‘t find the time to debug it.

@fzob
Copy link

fzob commented Jan 26, 2024

Indents are wrong on line 403-567. So custom attributes weren't written. After this fix setting sensor and sensor_temp works!

@mb1248 mb1248 marked this pull request as ready for review January 26, 2024 16:52
@mb1248
Copy link
Author

mb1248 commented Jan 26, 2024

@fzob I fixed it. Coverage could gave a hint on that 🤦 . Anyway, thanks for taking a look. Now, it also works for me.

@Patrick-DE
Copy link

@mb1248 I have added this quirk to my ZHA, now I am asking myself a very stupid question.
Is it correct that I am defining the external sensor by going to Manage Zigbee Device -> Cluster (In) -> Sensor, and write the IEEE of my temp sensor via the value?
Also, does it automatically use the external sensor temperature entity or do I still need an automation to push the temp entity of an external sensor into the SENSOR_TEMP entity?

@mb1248
Copy link
Author

mb1248 commented Jan 31, 2024

Hi @Patrick-DE, you need to add an automation. The sensor value is either internal (Default/0) or external, meaning that the internal temperature sensor is either used or not. If an external sensor is selected, the temperature value has to be set manually. This works similarly to how the Aqara hub operates. Note that, due to compatibility with Z2M, the temperature value is in centi-degrees (c°C), so you have to multiply it by 100. (This seems awkward, and I'm considering changing it.) I also read that the sensor type is reset; however, I didn't observe this in my test (around 2 hours). Therefore, the automation for Z2M, first, set the sensor type and then the temperature value.

@DamGranger
Copy link

DamGranger commented Feb 10, 2024

Hi, I'm trying to add an automation based on this quirk. Unfortunately I'm stuck when trying to pass the value of the external sensor...

That's what I'm trying to do and it ends up with 0° in the TRV current temperature :

service: zha.set_zigbee_cluster_attribute
data:
  cluster_type: in
  ieee: 54:ef:44:10:00:73:cb:f6
  endpoint_id: 1
  cluster_id: 64704
  attribute: 5010
  value: "{{ states('sensor.cl_chp_temperature')|float|round(1) * 100 }}"

It works fine when putting an hardcoded value like 2100, though...

Would you have any idea?

@tr4nt0r
Copy link
Contributor

tr4nt0r commented Feb 10, 2024

you have to pass an integer, after the multiplication add |int and it should work

@DamGranger
Copy link

DamGranger commented Feb 10, 2024

you have to pass an integer, after the multiplication add |int and it should work

service: zha.set_zigbee_cluster_attribute
data:
  cluster_type: in
  ieee: 54:ef:44:10:00:73:cb:f6
  endpoint_id: 1
  cluster_id: 64704
  attribute: 5010
  value: "{{ states('sensor.cl_chp_temperature')|float|round(1) * 100|int }}"

image

Nevermind, I'm stoopid...

That works with the right parenthesis

service: zha.set_zigbee_cluster_attribute
data:
  cluster_type: in
  ieee: 54:ef:44:10:00:73:cb:f6
  endpoint_id: 1
  cluster_id: 64704
  attribute: 5010
  value: "{{ (states('sensor.cl_chp_temperature')|float|round(1) * 100)|int }}"

Thanks

@DamGranger
Copy link

I someone wants to try your quirk that's how I made it work as a whole for one TRV, once I migrate the other 9, I'll just add some triggers and template up the ieee (or duplicate the actions if I can't generate the ieee in a template) :

alias: TH Mise à jour température vannes
description: Spécifique aux vannes Aqara SRTS-A01
trigger:
  - platform: state
    entity_id:
      - sensor.cl_chp_temperature
    id: parents
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - parents
            enabled: false
          - condition: template
            value_template: >-
              {{ (state_attr('climate.th_chp_thermostat',
              'current_temperature')|float -
              states('sensor.cl_chp_temperature')|float)|abs >= 0.1 }}
        sequence:
          - variables:
              sensor_temperature: >-
                {{ (states('sensor.cl_chp_temperature')|float|round(1) *
                100)|int }}
          - alias: Définir le capteur externe
            service: zha.set_zigbee_cluster_attribute
            data:
              cluster_type: in
              ieee: 54:ef:44:10:00:73:cb:f6
              endpoint_id: 1
              cluster_id: 64704
              attribute: 638
              value: "1"
            enabled: true
          - delay:
              hours: 0
              minutes: 0
              seconds: 3
              milliseconds: 0
            enabled: true
          - service: zha.set_zigbee_cluster_attribute
            data:
              cluster_type: in
              ieee: 54:ef:44:10:00:73:cb:f6
              endpoint_id: 1
              cluster_id: 64704
              attribute: 5010
              value: "{{ sensor_temperature }}"
            alias: Passer la température du capteur externe
mode: queued
max: 10

@StrandmonYellow
Copy link

StrandmonYellow commented Feb 28, 2024

Unfortunately this does not work for me. Turning on the external sensor command does get completed by homeassistant, but the entity state keeps saying 'off'. Additionally, i get an error when the temperature needs to be sent.
image

Can you maybe make a blueprint for this?

Update:
Solved it already. First had to add the custom quirk ofcourse :)

@Antoninj
Copy link

Hi. Is there any chance this gets merged soon? Is this blocked only by testing? If that’s the case, I can maybe help.

@mb1248
Copy link
Author

mb1248 commented Apr 28, 2024

@Antoninj I had no time to work on the test. The quirk is working. So only the testing is missing. Would be nice if you could help there.

@cpaius
Copy link

cpaius commented May 8, 2024

Thanks, it works for me too!

@hraschan
Copy link

hraschan commented May 15, 2024

It seem to work for a few people here. When can the PR get resolved? Is there still stuff to do? Would love to use the feature. :) I also tried the custom quirk and @DamGranger automation. Works like a charm

@Krzemq
Copy link

Krzemq commented Jul 17, 2024

How is it going? Will it be working? It's last thing i have on z2m :<

@sroettering
Copy link

Would love this feature as well :)

@rolfsan
Copy link

rolfsan commented Jul 27, 2024

Yes It would be nice👍

@DPellone
Copy link

DPellone commented Oct 5, 2024

Any update on this? It would be a nice feature to add 👍

@StrandmonYellow
Copy link

Is there any update on this?

@m00nyONE
Copy link

m00nyONE commented Mar 1, 2025

Can this be merged please? I really want to switch from z2m to zha and this is the only reason i cen't

@codesalatdev
Copy link

codesalatdev commented Mar 1, 2025

Can this be merged please? I really want to switch from z2m to zha and this is the only reason i cen't

The situation seems to be still the same, with tests missing in the PR.

@hraschan
Copy link

hraschan commented Mar 1, 2025

Can somebody add them? I thing that should be quick thing to do.

Antoninj added a commit to Antoninj/zha-device-handlers that referenced this pull request Mar 16, 2025
@Antoninj
Copy link

Antoninj commented Mar 23, 2025

Update: I've opened a new PR containing changes from this PR + the missing tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Xiaomi Request/PR regarding a Xiaomi device
Projects
None yet
Development

Successfully merging this pull request may close these issues.