Skip to content

Test input_select, wrong idea? #48

@andyinno

Description

@andyinno

Hi!

Thank you for this amazing piece of software. I am not a python guru but I used a lot appdaemon in the past.
I am starting with a different approach about how to use appdaemon and home assistant.

Basically I am splitting my "big classes" in small modules and everything is going to be saved in home assistant entities. This is now really easy because the helpers entities can be added directly in the front end.

Based on this, I have small classes that sets different partial config states. This is really helpful in order to debug the current state and adding some test to the class is straightforward.

I am facing with a doubt that I cannot solve alone.
I am rewriting the noone, someone, everyone status in appdaemon because the way appdaemon uses it, or how home assistant define the home/away does not suit my needs.
In order to re-implement it I am using an input_select with defined states.

My class is changing this status based on device_trackers.

and this is the relevant part of the class:

   def evaluate_state(self):
        noone = True
        everyone = True
        for person in self._persons:
            state = self.get_state(person)
            self.log("{} is {}".format(person, state))
            if state == "home":
                noone = False
            elif state == "not_home":
                everyone = False
        if noone:
            self.log("Evaluated noone at home")
            self.select_option(self._selector, "noone")
        elif everyone:
            self.log("Evaluated everyone at home")
            self.select_option(self._selector, "everyone")
        else:
            self.log("Evaluated someone at home")
            self.select_option(self._selector, "someone")

And now the question:

I don't find any way to check if select_option sets the right status. It seems that at the moment the select_option call is not wrapped. Running the test I see in the error message:

AttributeError: 'PersonAtHome' object has no attribute '_namespace'

Am I missing something obvious here?
Thank you in advance

Andrea

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions