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

Add support for Amazon Indoor Air Quality Monitor #1803

Merged
merged 10 commits into from
Jan 12, 2023
Merged

Conversation

Snid0
Copy link
Contributor

@Snid0 Snid0 commented Dec 22, 2022

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.

@alandtse
Copy link
Owner

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")
Copy link
Owner

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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?

Copy link
Owner

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)

Copy link
Owner

@alandtse alandtse left a 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.

@c3p0vsr2d2
Copy link

Works perfectly, thank you.
Two questions:

  1. Is there any way to set the polling interval specifically for the air quality monitors? The sensor does report new values every minute, but seems that the integration polls data every 3 minutes?
  2. I do not see new devices being created here, just additional entities - is this intended?

@alandtse alandtse merged commit 09915ea into alandtse:dev Jan 12, 2023
@Marcoletto
Copy link

HA see the entities but don't refresh them.
How can I solve?

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

Successfully merging this pull request may close these issues.

4 participants