Steer away from relying of device IDs. Itâs not recommended for many reasons Iâm too lazy to repeat, but to mention one, itâs a hassle should devices be replaced. Use entities and their states. HA is very much designed to work best using that.
Yes I donât disagree with you, but there are also advantages to using device as well.
Like A device is only ever one device, while an entity can be a group of devices (helpers). & this makes a big difference when designing blueprints E.g. trying to get the colour state doesnât work very well on a group.
But the main objective here is to figure out how to write A
You already have a solution, youâre not using it. Youâre going to need the entity_id anyways to get the state from the device, itâll just be extra code that literally does nothing because youâll just be matching it to the entity_id.
What happens when thereâs no lights on the device? what happens when thereâs 2 lights on the device? If youâre making this for other people, that will not work, youâll need the entity_id.
What do you mean by this? The target selector filters for only devices in the light domain?
I have thought about this, I think it is a limitation to the target selector that you canât limit multiples (i think). but that will be my next challenge to deal with multiples (but devices should be safe because it is only ever going to react to the first one & not thro a error).
Simply use a light selector. Donât bother with devices. What about users who use yaml? Cant create a device in yaml, making the blueprint useless for them. However entities work regardless.
But I like using area. I have a lot of lights in each area, & itâs easier to maintain. But sometimes i want to add an extra entity from another area E.g. âBack Gardenâ & the âMain lightâ from the âPatioâ. Or I want to use the same script for each room, but I also want to use the same code for a single entity.
Devices is not that necessary, but the code has a huge whole in it if you donât deal with the device option.
You know so much more than I about all of this stuff, but unless I have something fundamentally wrong, A target selector gives the user 3 options, âAreaâ, âEntityâ & âDeviceâ.
The idea behind that is to apply settings to all effected entities/devices. Not a single entity within a device. If youâre trying to filter to a single entity, your logic is flawed.
Why would it be flawed? I would think that if the user chooses the device option, they would be selecting A device that is a light? I realise that some devices may have multiple light entities (&or entities that are not A light) but 9/10 they would be selecting A bulb, (& mainly I just want the one selector to select either A âAreaâ or A âEntityâ but needed to deal with the device option).
Sorry for my ignorance, but I have only been looking at this stuff for about 2 months now. But I very much appreciate you sharing your knowledge with me.
If you can show me a better way of doing this (target at either an area &or A entity), or A better way of how to deal with the device option I would very much appreciate it?
You arenât sharing your endgoal. Youâre asking a question thatâs narrow sighted and expecting an answer for it. An area and a device can have more than 1 entity associated with it. The target selector can select multiples of everything. That means you should be tailoring your templates and actions to support more than 1 entity. Otherwise, use a different selector.
@petro please donât get annoyed with me, you have been such a huge help, & i very much appreciate your time, but I am still only a novice at this; & thus have some very stupid perceptions.