I have been thinking a lot about Home Assistant power automating things with all concepts related (entity, automation (trigger/condition/action), scripts, services, etc.) and I reach the best powerfull option to make a lot of things that are really dificult in HA:
The “homeassistat.change_entity” service
With this, you could change things like:
state of a entity (i.e. to make one entity sync with another entity, etc.)
attributes of a entity (i.e. changing the friendly name)
internal parameters (i.e the main is the scan_interval of a sensor). This is really useful and is very demanded around the forum:
scan waze-time only when go-to / come-from work (and not every minute ad-infinitum). [Reduce unnecesary servers usage, reduce database HA!!! ] . See too Scheduled polling for Tesla
disable bluetooth mi-flora plant scan when playing a film using a2dp bluetooth due to interferences [avoid posible interferences between sensors]
I understand that change the scan_interval parameter has a huge impact insede HA, but I think that for a really powerful automation system is a MUST_HAVE option.
entity_id = data.get('entity_id')
if not entity_id:
logger.error('No entity_id provided')
state = data.get('state')
if not state:
logger.error('No state provided')
hass.states.set(entity_id, state)
Now you have a service that can be called in automations. An example of action inside a automation:
So then. There will be a new service homeassistant/update_entity
that could be called to make a sensor “update” manually.
This could be really great, because you could
Define the sensors in HA with a fixed forever “scan_interval” was really annoying for a good automation system.
Now, I can i.e get 3 sensors waze travel-to-work time scanning one time a day, and execute ‘update_entity’ every minute when I am going to leave home, to see where of the 3 posibles ways are better.
Or i.e. get the result of a shell_command (because it has missed that doenst have any sensor to get the result of the command…). I can create a sensor “never” scaned, and force “update_entity” just after the command was executing, reading the result of the command…
(See Shell_command returned state )