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

gateway: remove click support for gateway devices #1229

Merged
merged 2 commits into from
Dec 14, 2021

Conversation

starkillerOG
Copy link
Contributor

@starkillerOG starkillerOG commented Dec 12, 2021

see home-assistant/core#61234 (comment)
the new python-miio release broke the alarm and light entity of the gateway

(by rytilahti: the click support was never working for these "subdevices" as they require to be initialized with the gateway instance. this fixes the issue by avoiding calling info()/accessing model – which is done automatically since #1038 – on a device instance that has no host nor token.)

@starkillerOG
Copy link
Contributor Author

@rytilahti could you have a look at this since the current HomeAssistant release the alarm and gateway light entities are broken

@codecov-commenter
Copy link

codecov-commenter commented Dec 12, 2021

Codecov Report

Merging #1229 (f893ce0) into master (b633844) will increase coverage by 3.10%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1229      +/-   ##
==========================================
+ Coverage   76.10%   79.20%   +3.10%     
==========================================
  Files          76       90      +14     
  Lines        8926     9696     +770     
  Branches      750     1130     +380     
==========================================
+ Hits         6793     7680     +887     
+ Misses       1950     1824     -126     
- Partials      183      192       +9     
Impacted Files Coverage Δ
miio/gateway/alarm.py 55.55% <ø> (-15.18%) ⬇️
miio/gateway/light.py 27.27% <ø> (-13.03%) ⬇️
miio/gateway/radio.py 52.50% <ø> (-6.20%) ⬇️
miio/gateway/zigbee.py 57.14% <ø> (-10.72%) ⬇️
miio/gateway/gatewaydevice.py 66.66% <100.00%> (-2.57%) ⬇️
miio/fan_miot.py 84.89% <0.00%> (-0.06%) ⬇️
miio/__init__.py 100.00% <0.00%> (ø)
miio/waterpurifier.py 100.00% <0.00%> (ø)
miio/viomivacuum.py
miio/roidmivacuum_miot.py
... and 69 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b633844...f893ce0. Read the comment docs.

@scxs535
Copy link

scxs535 commented Dec 12, 2021

@rytilahti same problem here.
@starkillerOG thanks

@rytilahti
Copy link
Owner

rytilahti commented Dec 12, 2021

The real fix is not removing the click support but to avoid doing model detection on those subdevices which do not have a host themselves, I overlooked this issue when I added the model detection, sorry...

I created a PR, but someone with a test device should give it a try before I merge it :-)

@scxs535
Copy link

scxs535 commented Dec 12, 2021

@rytilahti
how can we test this exactly?

@rytilahti
Copy link
Owner

rytilahti commented Dec 13, 2021

@scxs535 you have to clone this PR and use that checkout in your setup. If you are not sure how to do that in your system, it's easier to wait for now.

@starkillerOG could you please create a very simple test script to see what happens if you call info() or try to access model on alarm or light? That should crash, but if you take the couple of assignments from my earlier PR, it should start working again.

edit: oh, there's another option that's possible: pass the host, token et. al. to the gateway device constructors, so that they can acquire the info as usual. The downside is that those queries will not be routed through the main instance and will cause I/O, if I'm not mistaken?

@rytilahti rytilahti changed the title fix gateway devices gateway: remove click support for gateway devices Dec 13, 2021
@starkillerOG
Copy link
Contributor Author

Tested again and it works.
@rytilahti Could you revieuw again/merge?

@starkillerOG
Copy link
Contributor Author

@scxs535 you have to clone this PR and use that checkout in your setup. If you are not sure how to do that in your system, it's easier to wait for now.

@starkillerOG could you please create a very simple test script to see what happens if you call info() or try to access model on alarm or light? That should crash, but if you take the couple of assignments from my earlier PR, it should start working again.

edit: oh, there's another option that's possible: pass the host, token et. al. to the gateway device constructors, so that they can acquire the info as usual. The downside is that those queries will not be routed through the main instance and will cause I/O, if I'm not mistaken?

I don't really want to do any calls from the subdevice itself, but only invoke calls to the parent object (gateway). Also because the message id will not be properly incremented which could potentially cause issues. (otherwise there would be 2 messages ids that are incrementing at diffrent times and that could get messy).

Copy link
Owner

@rytilahti rytilahti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for stepping up so quickly to fix this @starkillerOG! 👍

@rytilahti rytilahti merged commit ee88751 into rytilahti:master Dec 14, 2021
@rytilahti rytilahti added the bug label Dec 14, 2021
rytilahti added a commit that referenced this pull request Dec 14, 2021
This release fixes regressions caused by the recent refactoring related to supported models:
* philips_bulb now defaults to a bulb that has color temperature setting
* gateway devices do not perform an info query as that is handled by their parent

Also, the list of the supported models was extended thanks to the feedback from the community!

[Full Changelog](0.5.9.1...0.5.9.2)

**Implemented enhancements:**

- Add yeelink.bhf\_light.v2 and yeelink.light.lamp22 support [\#1250](#1250) ([FaintGhost](https://github.com/FaintGhost))
- Skip warning if the unknown model is reported on a base class [\#1243](#1243) ([rytilahti](https://github.com/rytilahti))
- Add emptying bin status for roborock s7+ [\#1190](#1190) ([rytilahti](https://github.com/rytilahti))

**Fixed bugs:**

- Fix Roborock S7 fan speed [\#1235](#1235) ([shred86](https://github.com/shred86))
- gateway: remove click support for gateway devices [\#1229](#1229) ([starkillerOG](https://github.com/starkillerOG))
- mirobo: make sure config always exists [\#1207](#1207) ([rytilahti](https://github.com/rytilahti))
- Fix typo [\#1204](#1204) ([com30n](https://github.com/com30n))

**Merged pull requests:**

- philips\_eyecare: add philips.light.sread1 as supported [\#1246](#1246) ([rytilahti](https://github.com/rytilahti))
- Add yeelink.light.color3 support [\#1245](#1245) ([Kirmas](https://github.com/Kirmas))
- Use codecov-action@v2 for CI [\#1244](#1244) ([rytilahti](https://github.com/rytilahti))
- Add yeelink.light.color5 support [\#1242](#1242) ([Kirmas](https://github.com/Kirmas))
- Add more supported devices to their corresponding classes [\#1237](#1237) ([rytilahti](https://github.com/rytilahti))
- Add zhimi.humidfier.ca4 as supported model [\#1220](#1220) ([jbouwh](https://github.com/jbouwh))
- vacuum: Add t7s \(roborock.vacuum.a14\) [\#1214](#1214) ([rytilahti](https://github.com/rytilahti))
- philips\_bulb: add philips.light.downlight to supported devices [\#1212](#1212) ([rytilahti](https://github.com/rytilahti))
@rytilahti rytilahti mentioned this pull request Dec 14, 2021
rytilahti added a commit that referenced this pull request Dec 14, 2021
This release fixes regressions caused by the recent refactoring related to supported models:
* philips_bulb now defaults to a bulb that has color temperature setting
* gateway devices do not perform an info query as that is handled by their parent

Also, the list of the supported models was extended thanks to the feedback from the community!

[Full Changelog](0.5.9.1...0.5.9.2)

**Implemented enhancements:**

- Add yeelink.bhf\_light.v2 and yeelink.light.lamp22 support [\#1250](#1250) ([FaintGhost](https://github.com/FaintGhost))
- Skip warning if the unknown model is reported on a base class [\#1243](#1243) ([rytilahti](https://github.com/rytilahti))
- Add emptying bin status for roborock s7+ [\#1190](#1190) ([rytilahti](https://github.com/rytilahti))

**Fixed bugs:**

- Fix Roborock S7 fan speed [\#1235](#1235) ([shred86](https://github.com/shred86))
- gateway: remove click support for gateway devices [\#1229](#1229) ([starkillerOG](https://github.com/starkillerOG))
- mirobo: make sure config always exists [\#1207](#1207) ([rytilahti](https://github.com/rytilahti))
- Fix typo [\#1204](#1204) ([com30n](https://github.com/com30n))

**Merged pull requests:**

- philips\_eyecare: add philips.light.sread1 as supported [\#1246](#1246) ([rytilahti](https://github.com/rytilahti))
- Add yeelink.light.color3 support [\#1245](#1245) ([Kirmas](https://github.com/Kirmas))
- Use codecov-action@v2 for CI [\#1244](#1244) ([rytilahti](https://github.com/rytilahti))
- Add yeelink.light.color5 support [\#1242](#1242) ([Kirmas](https://github.com/Kirmas))
- Add more supported devices to their corresponding classes [\#1237](#1237) ([rytilahti](https://github.com/rytilahti))
- Add zhimi.humidfier.ca4 as supported model [\#1220](#1220) ([jbouwh](https://github.com/jbouwh))
- vacuum: Add t7s \(roborock.vacuum.a14\) [\#1214](#1214) ([rytilahti](https://github.com/rytilahti))
- philips\_bulb: add philips.light.downlight to supported devices [\#1212](#1212) ([rytilahti](https://github.com/rytilahti))
@manu3b1
Copy link

manu3b1 commented Dec 15, 2021

With 0.5.9.2 release, with a lumi.gateway.v3-MW300, Alarm and Luminance entities are present, but still no Light.

@rytilahti
Copy link
Owner

@manu3b1 please open a new issue on that and provide some logs so that we have something that can be used to figure out why it isn't working. @starkillerOG do you have a v3? Are you also experiencing the missing light?

@manu3b1
Copy link

manu3b1 commented Dec 15, 2021

Light is back with HA 2021.12.2.
Thx!

@scxs535
Copy link

scxs535 commented Dec 15, 2021

everything(alarm & light) works well as before after update to 2021.12.2. 👍
thanks @starkillerOG @rytilahti

@rytilahti
Copy link
Owner

Glad to hear it's working and sorry for the inconvenience! It's rather hard to perform refactoring already on a code base size of this even when one tries to be careful.. Thanks for reporting back @scxs535 :-)

@maury77
Copy link

maury77 commented Dec 15, 2021

for me no , I have removed the integration and now

Nuovo tentativo di configurazione: DeviceException during setup of xiaomi gateway with host {self._host}

@starkillerOG
Copy link
Contributor Author

I tested on my setup with gateway.v3 and both the alarm, illumination and light entities all work on the latest 2012.12.2 release.

@maury77 do you have anything else in the log?
Did you set it up using the cloud credentials and are you sure you have the correct credentials and selected the correct server?

@maury77
Copy link

maury77 commented Dec 16, 2021

The cloud connectio si ok

image

configuration

image

but

image

dic 16 09:42:19 sdomotica homeassistant[32525]: 2021-12-16 09:42:19 WARNING (MainThread) [homeassistant.config_entries] Config entry 'hub mare' for xiaomi_miio integration not ready yet: DeviceException during setup of xiaomi gateway with host {self._host}; Retrying in background

Seems a timeout but the device is reacheble

image

I upgrade the version of the device to 3.1.3_0004

@starkillerOG
Copy link
Contributor Author

@maury77 did you try power cycling the hub (plugin out, wait 15 seconds, plug back in)?
Did this hub work before for you?

@maury77
Copy link

maury77 commented Dec 16, 2021

In this moment I can't turn it off because the gw is in other city, before
it worked in 2012.11.X

but i also updated the firmware

therefore the combination of new firmware and new Ha has never been tested

@starkillerOG
Copy link
Contributor Author

@maury77 if possible could you try the old HA version 2021.11.X with the new firmware to make sure it is not a firmware problem?
(maybe in a dev enviroment if you have one).

@starkillerOG
Copy link
Contributor Author

I dont have a aqhm01 gateway (I have v3) so I cant test myself, the .v3 gateway works with HA 2021.12.2

@maury77
Copy link

maury77 commented Jan 6, 2022

I dont have a aqhm01 gateway (I have v3) so I cant test myself, the .v3 gateway works with HA 2021.12.2

With last version and reboot now is ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants