Hi guys, I’ve been trying to set it for hours that when the input boolean is turned on the TV lowers the volume to 15% and if you try to raise the volume it puts it back to 15% until the input boolean turned off
I would do it this way. It would trigger on each and every volume change so there is no opportunity to ever miss a threshold being crossed. Pro = resiliency. Con = increased log traffic.
I do have a question about this because I just went through a, “the TV is too loud but a volume number means nothing” project. If that is the same use-case, there are other approaches that don’t use a fixed volume number that may be worth discussing. But off topic.
Simply when the input boolean is active as the first thing the automation sets the TV volume to 15% and if someone tries to raise it is automatically put to 15 until I turn off the input boolean.
Are they good as information?
I think @huu is correct.
And I would remove the while thing at the end as it’s not needed. It will just block the automation from triggering again.
alias: volume test 1
description: ''
trigger:
- platform: numeric_state
entity_id: media_player.sony_bravia_tv
above: '0.16'
attribute: volume_level
- platform: state
entity_id: input_boolean.buonanotte
to: 'on'
condition:
- condition: state
entity_id: input_boolean.buonanotte
state: 'on'
action:
- service: media_player.volume_set
data:
volume_level: 0.15
target:
entity_id: media_player.tv_salotto
mode: single
What @crlogic posted should also work with 0.16 but it won’t trigger on boolean on.
If the volume is 0.4 when the boolean goes on then nothing happens until the volume has been changed.
I don’t know what your entities are named but I do notice that you are triggering on one media_player and doing the action on a different media_player.
Is that correct?
If this sets a new volume then the code I posted (with corrected media player) should also work.
If that doesn’t work then you need to post the automation trace so that we can see what is the issue.
I don’t think the automation you posted last is something you should use.
In you last post, You change your trigger to be the change in input boolean and not change in volume (the trigger and the condition are the same? which i found a bit odd)