I can’t seem to find any clarity on this subject. Is there a detailed guide that explains when to use which and why?
Also, sometimes I see data:
indented under entity_id:
and sometimes I don’t. It feels very inconsistent.
I can’t seem to find any clarity on this subject. Is there a detailed guide that explains when to use which and why?
Also, sometimes I see data:
indented under entity_id:
and sometimes I don’t. It feels very inconsistent.
In general, when calling a service, it’s data or data_template (depending on whether or not you’re using a template.) And, in general, for a template condition/sensor/etc., it’s value_template. But basically, you need to check the documentation (e.g., components or docs) for what you’re trying to do. There are some inconsistencies that (I would guess) are probably there for historic reasons.
Regarding your second question, again, when calling a service, everything goes under data … except, there are some shortcuts implemented. E.g., entity_id does not generally need to go under data (or data_template.) The implementation will automatically add it to data. So, when calling a service that only needs entity_id, you can do it one less line. But you could put it under data if you wanted (or under data_template if you needed.) So:
service: some_service
entity_id: blah.blah
is just a shortcut for:
service: some_service
data:
entity_id: blah.blah
At least, this is based on my experience so far using HA and reading some of the code.