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

get_alerts() only returns first alert in list #30

Open
tbl-benjamin opened this issue Apr 2, 2021 · 3 comments
Open

get_alerts() only returns first alert in list #30

tbl-benjamin opened this issue Apr 2, 2021 · 3 comments

Comments

@tbl-benjamin
Copy link
Contributor

Not sure if this is intended or not, but it seems kind of useless to only return the first alert in the list. Although, it seems the alerts are pretty useless in general if they can only be used to send emails to a recipient; it would be nice to know if there is a way of accessing/intercepting these alerts from the stat.

@doug-hoffman
Copy link
Collaborator

The get_alerts() behavior was fixed in 632a6d3, which made it into 0.14 yesterday. The official local API offers no means to configure or control alerts; only receive the state of alerts (active or not).

If you plan on looking into unofficial API values to manage alerts, it seems like the best path forward may be to come up with a single method for handling unofficial API calls, along the lines of:

    def set_unofficial(self, settings):
        path = "/settings"
        data = urllib.parse.urlencode(settings)
        r = self._request(path, data)
        return self.parse_response(r, 'set_unofficial')

This way, you're free to set any values you wish, but aren't littering the class with calls that aren't guaranteed to work on at least a majority of the models. Constants could still be defined within the class, but maybe named for the specific model known to support it, such as T2100_ALERT_FOO. Then you could just set_unofficial({T2100_ALERT_FOO: T2100_ALERT_FOO_ON}), set_unofficial({T2100_ALERT_FOO: T2100_ALERT_FOO_ON, T2100_ALERT_BAR: T2100_ALERT_BAR_OFF}), or even set_unofficial({'some_alert': 1}) as required.

@hpeyerl
Copy link
Owner

hpeyerl commented Apr 6, 2021

I do think that's a good idea, @tbl-benjamin ...

@garbled1
Copy link
Collaborator

I actually really like the behavior as-is, because it's perfect for a homeassistant binary_sensor. If you do change this, could you make it a new api call instead?

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

No branches or pull requests

4 participants