Fade Out/Fade In

Hi there,

I want to do the following:

Determine the volume level of an entity, decrease the volume level of that entity slowly, change playlist and increase the volume level of the determined volume level.

May anybody help me here?

Thanks a lot!

Greets from Germany
Daniel

AFAIK unlike with lights, for volume we do not have a transition time within HomeAssistant. So that means, you will have to do it manually.

I use this in my AlarmClock to slowly fade my speakers volume higher:

[{"id":"7333079d.8b6648","type":"traffic","z":"1de400c0.5ce76f","name":"Turn Up Volume","property_allow":"payload","filter_allow":"start","ignore_case_allow":false,"negate_allow":false,"send_allow":false,"property_stop":"payload","filter_stop":"snooze","ignore_case_stop":false,"negate_stop":false,"send_stop":false,"default_start":false,"differ":false,"x":640,"y":1240,"wires":[["f33856e4.d23368"]]},{"id":"2a6d1f1f.3c584","type":"inject","z":"1de400c0.5ce76f","name":"Volume ---->","topic":"","payload":"volume","payloadType":"flow","repeat":"40","crontab":"","once":false,"onceDelay":0.1,"x":260,"y":1240,"wires":[["7333079d.8b6648"]]},{"id":"5662301f.21a64","type":"function","z":"1de400c0.5ce76f","name":"Set Volume","func":"newmsg = {};\nvar volume = flow.get(\"volume\");\n\nnewmsg.payload = { data: { \"volume_level\":volume} }\n\nreturn newmsg;","outputs":1,"noerr":0,"x":950,"y":1240,"wires":[["f29cf51d.352b18"]]},{"id":"f29cf51d.352b18","type":"api-call-service","z":"1de400c0.5ce76f","name":"Bett","server":"2fba4297.e4145e","version":1,"debugenabled":false,"service_domain":"media_player","service":"volume_set","entityId":"media_player.snapcast_schlafzimmer","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1110,"y":1240,"wires":[["151ef3c1.df7b0c"]]},{"id":"583af9fa.30a278","type":"function","z":"1de400c0.5ce76f","name":"Increment Volume","func":"var volume = flow.get('volume')||0;\n\nif (volume < 0.5) {\n    volume = volume + 0.01;\n    flow.set(\"volume\", volume);\n    \n    newmsg = {\"payload\":\"looping\"}\n    return newmsg;\n}\nelse {\n    newmsg = {\"payload\":\"done\"};\n    return newmsg;\n}","outputs":1,"noerr":0,"x":1590,"y":1240,"wires":[[]]},{"id":"4baf3e74.26576","type":"function","z":"1de400c0.5ce76f","name":"Set Volume","func":"newmsg = {};\nvar volume1 = flow.get(\"volume1\");\n\nnewmsg.payload = { data: { \"volume_level\":volume1} }\n\nreturn newmsg;","outputs":1,"noerr":0,"x":950,"y":1320,"wires":[["558130a3.34ebf"]]},{"id":"558130a3.34ebf","type":"api-call-service","z":"1de400c0.5ce76f","name":"TV","server":"2fba4297.e4145e","version":1,"debugenabled":false,"service_domain":"media_player","service":"volume_set","entityId":"media_player.snapcast_schlafzimmer_tv","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1110,"y":1320,"wires":[["2cf38eb7.931382"]]},{"id":"6ccf26e6.557f38","type":"function","z":"1de400c0.5ce76f","name":"Increment Volume1","func":"var volume1 = flow.get('volume1')||0;\n\nif (volume1 < 0.5) {\n    volume1 = volume1 + 0.01;\n    flow.set(\"volume1\", volume1);\n    \n    newmsg = {\"payload\":\"looping\"}\n    return newmsg;\n}\nelse {\n    newmsg = {\"payload\":\"done\"};\n    return newmsg;\n}","outputs":1,"noerr":0,"x":1590,"y":1320,"wires":[[]]},{"id":"97e9815d.b72dc","type":"inject","z":"1de400c0.5ce76f","name":"Volume1 ---->","topic":"","payload":"volume1","payloadType":"flow","repeat":"60","crontab":"","once":false,"onceDelay":0.1,"x":260,"y":1320,"wires":[["628d4533.f4b12c"]]},{"id":"628d4533.f4b12c","type":"traffic","z":"1de400c0.5ce76f","name":"Turn Up Volume","property_allow":"payload","filter_allow":"start","ignore_case_allow":true,"negate_allow":false,"send_allow":false,"property_stop":"payload","filter_stop":"snooze","ignore_case_stop":false,"negate_stop":false,"send_stop":false,"default_start":false,"differ":false,"x":640,"y":1320,"wires":[["5c7aa8a0.347508"]]},{"id":"151ef3c1.df7b0c","type":"api-current-state","z":"1de400c0.5ce76f","name":"Loudness","server":"2fba4297.e4145e","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"media_player.snapcast_schlafzimmer","state_type":"num","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1300,"y":1240,"wires":[["f1e415fc.fd7d18"]]},{"id":"2cf38eb7.931382","type":"api-current-state","z":"1de400c0.5ce76f","name":"Loudness","server":"2fba4297.e4145e","version":1,"outputs":1,"halt_if":"","halt_if_type":"num","halt_if_compare":"is","override_topic":true,"entity_id":"media_player.snapcast_schlafzimmer_tv","state_type":"num","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1300,"y":1320,"wires":[["462327ac.3031d8"]]},{"id":"f33856e4.d23368","type":"api-current-state","z":"1de400c0.5ce76f","name":"Spotify?","server":"2fba4297.e4145e","version":1,"outputs":2,"halt_if":"playing,unavailable","halt_if_type":"str","halt_if_compare":"does_not_include","override_topic":true,"entity_id":"media_player.spotify","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":800,"y":1240,"wires":[[],["5662301f.21a64"]]},{"id":"5c7aa8a0.347508","type":"api-current-state","z":"1de400c0.5ce76f","name":"Spotify?","server":"2fba4297.e4145e","version":1,"outputs":2,"halt_if":"playing,unavailable","halt_if_type":"str","halt_if_compare":"does_not_include","override_topic":true,"entity_id":"media_player.spotify","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":800,"y":1320,"wires":[[],["4baf3e74.26576"]]},{"id":"f1e415fc.fd7d18","type":"switch","z":"1de400c0.5ce76f","name":"","property":"data.attributes.volume_level","propertyType":"msg","rules":[{"t":"lte","v":"0.5","vt":"num"},{"t":"gte","v":"0.5","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1430,"y":1240,"wires":[["583af9fa.30a278"],[]]},{"id":"462327ac.3031d8","type":"switch","z":"1de400c0.5ce76f","name":"","property":"data.attributes.volume_level","propertyType":"msg","rules":[{"t":"lte","v":"0.5","vt":"num"},{"t":"gte","v":"0.5","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1430,"y":1320,"wires":[["6ccf26e6.557f38"],[]]},{"id":"2fba4297.e4145e","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true}]

Basically what i do there:

First i define a variable with the volume. The Volume will then be incremented up based on a repeating timer (i.e.: every 20sec). I believe in the meantime you can also just call the volume_up service that didnt exist in the past. That should make it even easier.

Hi Marcus,

I will give it a try and post the whole project (when it’s working) in the “Share your projects!” section!

Thanks at the moment for your help!

Greets
Daniel