Adds useful attributes to RainMachine programs and zones#14087
Adds useful attributes to RainMachine programs and zones#14087balloob merged 13 commits intohome-assistant:devfrom
Conversation
There was a problem hiding this comment.
We should just use mac and type. I don't know what entity id is ?
There was a problem hiding this comment.
MAC and type aren't sufficient – in that case, every program would have the same unique ID (e.g., "abcdef1234_program"). Same with zones. entity_id is the ID of that specific program or zone, which gives results like "abcdef1234_program_2". Let me know if I'm thinking about this wrong or doing the job in a confusing manner.
There was a problem hiding this comment.
That makes sense. Got confused because Home Assistant also has the concept of entity ids.
There was a problem hiding this comment.
We should never have relative time in the attributes.
There was a problem hiding this comment.
We should only store information in the attributes that is relevant in further explaining the state.
There was a problem hiding this comment.
Just because we have the data, doesn't mean that we should add it to our state machine.
There was a problem hiding this comment.
I've been a tad over-zealous. 😄 Question: what about attributes that don't relate directly to the state, but would still be useful in influencing the state? Example: I have an attribute for soil type; it'd be great to use this in my automations for the switch itself (e.g., "If the temperature goes above 80 degrees, stop watering zones with Clay Loam soil").
There was a problem hiding this comment.
That can stay. I guess that is similar to things like max_temp for climate devices.
There was a problem hiding this comment.
Thanks, @balloob. I've removed all frivolous attributes and all attributes that (a) aren't directly related to the state and (b) aren't useful in influencing the state through automation. Let me know your thoughts?
| @callback | ||
| def _program_updated(self): | ||
| """Update state, trigger updates.""" | ||
| self.schedule_update_ha_state(True) |
There was a problem hiding this comment.
Use async_schedule_update_ha_state.
There was a problem hiding this comment.
Got it. For my own knowledge, this is because the @callback decorator declares that anything in the method body is safe for the event loop, yes?
There was a problem hiding this comment.
Yes! When the dispatcher calls this method it uses the core method async_add_job which checks if the function/method has been decorated with callback, and if so, schedules a call to it on the event loop. Otherwise it will be run in the thread pool (if it's not a coroutine or coroutine function).
…ant#14087) * Starting to add attributes * All attributes added to programs * Basic zone attributes in place * Added advanced properties for zones * Working to move common logic into component + dispatcher * We shouldn't calculate the MAC with every entity * Small fixes * Small adjustments * Owner-requested changes * Restart * Restart part 2 * Added ID attribute to each switch * Collaborator-requested changes
Description:
This PR adds several useful attributes to RainMachine programs and zones, including:
Additionally, under the hood, the process of migrating common RainMachine data/logic into the component created by #14225 starts.
Related issue (if applicable): N/A
Pull request in home-assistant.github.io with documentation (if applicable): N/A
Example entry for
configuration.yaml(if applicable):Checklist:
tox. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
- [ ] Documentation added/updated in home-assistant.github.ioIf the code communicates with devices, web services, or third-party tools:
- [ ] New dependencies have been added to theREQUIREMENTSvariable (example).- [ ] New dependencies are only imported inside functions that use them (example).- [ ] New dependencies have been added torequirements_all.txtby runningscript/gen_requirements_all.py.- [ ] New files were added to.coveragerc.