in normal services (I.e. action section, script sequence section, etcâŚ), itâs data.
EDIT: I have a feeling that youâre over thinking this. When in doubt, consult the docs. Thereâs no rule. data/service_data are just the names of the field and the docs will tell you if the name of the field is valid or not.
Thanks for responding. I asked BECAUSE I consulted the docs.
Search Docs for âservice_dataâ and you get an unhelpful Lovelace changelog page
Search Docs for âdataâ and you get irrelevant result overload
Search Docs for âswitch.toggleâ and you see references to âService Dataâ but nothing about when or where to use service_data
Does anyone know any docs that cover this? Iâd like to write a PR for clarification.
Let me fix that for you ⌠what youâre really saying is follow the docs, but donât rely on being able to search the docs with the search button on the docs.
No, Iâm saying look for what youâre looking for in the docs.
You wanted to know what keys are accepted by the tap_action lovelace item, and what keys are accepted by the switch integration, but you searched for âdataâ and âservice_dataâ.
If I wanted to know how to replace the batteries in a drone , I would search for the model of the drone. If I searched for batteries Iâd never find the right page.
I already answered this. Itâs only used in tap_action. Also there is 1000+ integrations, itâs possible that one of them use the same field name. Why do you want to know where itâs used anyways? It only has the name service_data for tap action to let you know itâs only valid with a call service tap action.
Indeed, the keys are relevant to their parents. Doesnât matter what integrations use what keys, it matters what keys work with the integration youâre using.
OP is trying to do things backwards and getting confused.
You seem to be confused by my original post. Iâm not trying to âdoâ anything except to understand how and where service_data is used.
I had clearly already read the docs to know it is used in lovelace, but I wanted to know if is it also used anywhere else? Searching the docs was inconclusive, so I asked. Thanks, petro, for answering.
The rest of this thread reflects a rigidity of thinking that surprises me. Why would I want to know that? Why not? X requires Y. Great. Does anything else require Y? Who wouldnât want to know? Perhaps if you already know the answer, itâs harder to understand why someone else would ask.
And please think twice before parroting 'follow the docs". I understand the need to encourage people to read the docs, but petroâs answer is not in the docs, except by exclusion.
very much looking forward to that. always good when experts try to improve the docs. would hope the difference between frontend en backend is clear on your side before you do that though.
The problem with a PR like that is it doesnât clarify anything. If we add a blurb about a service_data field inside actions, itâs just going to confuse people because actions require the data field. The only acceptable place to write anything would be in the service_data field under tap_action, which IMO is already covered well.
If anything, this thread just shows you how bad the home-assistant.io search engine still is (even after the recent search engine changes).
Itâs not ârigidity of thinkingâ itâs about doing things the correct way around. Making docs for every subkey would just make the docs a million times more complicated.
What makes more sense, and what the docs currently do, is that for each integration they list all the available options.
I presume that you donât intend to only purchase iot gadgets for your home that use a certain key in their configuration? Youâre going to buy a gadget that you need and then configure it with the keys that the integration uses.
What I was trying to convey to you is that trying to find âwhich integrations use which keyâ is the wrong way round, it should be âwhich keys does this integration useâ.
The answer is already in the documentation if you look for it the correct way round.
tbh, I was a bit sarcastic. shouldnât have done that. sorry. Itâs just that when people start accusing others so bluntly of âparrotingâ and being ârigidâ, while in fact they are most helpful, and most of all, simply right, it makes me itchy.
Found it somewhat amusing that a fellow community-member, while not being clear on the subject at hand, feels the urge of writing a PR.
Again, I shouldnât have.
Have a great day yâall.
Iâm not saying a PR wouldnât be helpful. Iâm trying to clarify where the PR should go if we were to make changes. I do think that the tap_action examples section could be expanded and the example used directly in the service_data field isnât the best option. light.turn_on for service and brightness: 255 for service_data would be a better fit because entity_id is not required to be inside the data. However it would be required for that specific service_data in order for it to work.
of course, that could be done. Improving the docs is always a good thing.
OP was confused by the frontend and backend though, and put forward examples that have no relation whatsoever. tap_action is never in the backend, so why compare apples and pears.
And that we donât need (service_)data: in the backend when only an entity_id is used without further data has been clear since forever. If that isnât in the docâs, it should be added, since it cuts another extra line of yaml
It is in the docs, thatâs what was ironic about it all. The docs for switch I linked to above donât use the data key because their is no extra service data, they just use entity_id.
Also, the code in the docs is (supposed to be, and 99.9% of the time is) best practice, but itâs not the only way to do things. This is also explained in the docs right back in the âgetting startedâ sections.
Yaml anchors arenât mentioned explicitly in the docs for example, as theyâre not considered âbest practiceâ because they confuse new users, but in the getting started docs they explain that all configuration is yaml and valid yaml is accepted. In fact, you could rewrite your entire configuration on json if you want, it would still work, but documenting that just makes it more confusing for new users.
as said, if no further data is used, one can suffice with the action service and entity_id. If specific settings are required, we need the data: field.
would improve the docs, with the above reasoning added to it.
now donât get me started, Ive today cut many many lines and made my config so much easier to maintain using only a few new anchors (Frontend and backend)
Again though, just because something can be done doesnât make it best practice.
You can use all sorts of weird and wonderful ways of quoting things in single line templates, but all the docs are written with double quotes on the outside and single quotes inside. Just makes it easier for new users to understand it without making the docs too complicated to understand.
With turning on a light, using data is the best practice because you can also pass brightness and colour. Although turning off should only be entity_id imho as there is no other data to pass other than the entity_id for that service.
Iâm not confused about frontend and backend â yes tap_action is only used in the
frontend, what I was asking is if service_data is only used with tap_action.
And when someone says you have to look for things âthe correct way roundâ that seems like the definition of rigid thinking.
I have written PRs for clarification that were accepted and published. I donât know everything, but that means I sometimes see ways to make things more clear for others who donât know everything.
That said, this issue is now burned into my brain and Iâm not sure I see a way (or need) to clarify. Perhaps I am the only one who will ever wonder about the lowly service_data and its meager existence under the thumb of tap_action.