-
Notifications
You must be signed in to change notification settings - Fork 303
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
Add support for Amazon Indoor Air Quality Monitor #1803
Conversation
Thanks, I do recommend you learn how to use a git client so you don't have to use the GitHub website to add files. It will also make it easier for you to experiment. |
for cap in appliance["capabilities"]: | ||
instance = cap.get("instance") | ||
if instance : | ||
friendlyName = cap["resources"].get("friendlyNames") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it pretty clear the key resources
will exist in instance
exists? Want to avoid keyerrors for the majority of users who do not have IAQM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code should only run if the appliance matches based on below.
if appliance["friendlyDescription"] == "Amazon Indoor Air Quality Monitor" :
I can only test against my device, but yes if instance existed there was always resources too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any neater way of traversing down the keys than using get? Is get the only safe way if you are unsure if the key is there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had missed it was nested in that if. That should be fine. But safest way is either nested gets or checking for keys before access.
Each level of nesting can be done like this with a get.
something.get("key1", {}).get("key2", DEFAULT)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this. I haven't tested it, but just have some questions for you. It doesn't necessarily mean make code changes but would like your thoughts.
Works perfectly, thank you.
|
HA see the entities but don't refresh them. |
These changes will create 6 new sensors for each amazon air quality sensor detected. These get updated each time the component polls the alexa API. No updates are recieved on websockets.
Indoor Air Quality
Temperature
Humidity
Particulate Matter
Carbon Monoxide
Volitile Organic Compounds
I pretty much copied the way the existing temperature sensor functionality worked. Expanding this to the extera sensors.