First things first, if your problem is solved, it is always a nice idea to mark the corresponding post (in this case the first answer from @madface
) as solution. It not only shows the appreciation for the one who helped, it also shows the thread as solved, so others can either skip (no more help needed) or look into the thread for a working solution. Thanks for that.
I’d also like to offer another solution or better an explanation, why your code @Okcool might be not working. The main problem is, you’re trying to do “everything” in the trigger. In cases like this, it is mostly better, to split this into trigger
and condition
. This is because trigger
s are very specific in when they fire the trigger event.
My guess is, that is what @madface meant by “State triggers would (often) not work”. Here is the part from the support page, that is interesting:
Fires when the state of any of given entities changes. If only entity_id
is given, the trigger will fire for all state changes, even if only state attributes change. If at least one of from
, to
, not_from
, or not_to
are given, the trigger will fire on any matching state change, but not if only attributes change. To trigger on all state changes, but not on changed attributes, set at least one of from
, to
, not_from
, or not_to
to null
.
So in your case I’d try it like this:
trigger:
- platform: state
entity_id: sensor.oppo_bluetooth_connection
condition:
- condition: state
entity_id: sensor.oppo_bluetooth_connection
attribute: connected_paired_devices
state: "2C:DC:AD:C5:A8:C6 (VW)"
That way it triggers with every change of the state and attributes of the sensor
and checks afterwards if the change is something to react on.
And another note (as well from the docs):
Use quotes around your values for from
and to
to avoid the YAML parser from interpreting values as booleans.
So, yes, welcome to the loony bin (forum)! And just to be clear, the way @madface
suggested is correct and valid in the same way mine is, it is just a personal choice!