Your favourite automations

I used sun.sun too. But the below horizon and above isn’t perfect to me. Most the times when the sun is just above the horizon, it’s still shady/dark outside. I fine tuned it a bit and use the deconz daylight sensor and got it set if its sunrise or golden_hour_2 then do not turn on. Otherwise turn on.

It has more states to fine tune it to your needs.

This is one that I just created and am pretty happy with. It combines a HA automation and an automation in the shortcut app on iOS.

In short, if I am home and connected to my Wifi, when I open a music app the automation turns on my receiver (in airplay mode) and connects my phone to the receiver (over airplay)

iPhone side of things.

If any of my music apps are opened, it starts the iPhone automation.

This automation turns on an input_boolean in Home Assistant (more on this later)
It then checks if I am connected to my home wifi network and if I am it switches audio output to airplay.

On the HA side of things. The input_boolean triggers automation to turn on the receiver but only if I am home and connected to my home wifi.

  - alias: "Turn on Amp With Music App"
    initial_state: true
    trigger:
      - platform: state
        entity_id: input_boolean.adamphonemusic
        to: 'on'
    action:
      - service: homeassistant.turn_off
        entity_id: input_boolean.adamphonemusic
      - condition: and
        conditions:
          - condition: state
            entity_id: person.adam
            state: 'home'
          - condition: state
            entity_id: sensor.adams_iphone_ssid
            state: 'Ubiquiti'
      - service: media_player.turn_on
        entity_id: media_player.rx_v481_dccace_main
      - delay: 00:00:05
      - service: media_player.select_source
        data:
          entity_id: media_player.rx_v481_dccace_main
          source: airplay

1 Like

I’ve just created a new automation with node-red to get a music control for each room.
Recently i switched all my zigbee devices to the conbee II Stick.
I bought some ikea tradfri devices to play around with it.
Now I use the Ikea Tradfri remote control for my music control.
Node-Red listen to the events from the remote and controls my echo devices.

[{"id":"fbd9babc.68de18","type":"server-events","z":"acb2a3ee.cd01c","name":"Deconz Trötfri ","server":"dc4a800c.88fbb","event_type":"deconz_event","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":true,"x":110,"y":2560,"wires":[["a5211ca9.c46fd","5359b3ce.b6091c","9b350392.c5db7","8d342af4.dec9f8","217df9c8.714e96"]]},{"id":"a5211ca9.c46fd","type":"function","z":"acb2a3ee.cd01c","name":" volume up Event 2002","func":"event = msg.payload.event.event;\nid = msg.payload.event.id\n\nif (event == 2002 && id == 'tradfri_fernbedienung') {\n     return [msg, null];\n     \n} else {\n   return null;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":360,"y":2440,"wires":[["7870e5d8.ad513c"]]},{"id":"7870e5d8.ad513c","type":"alexa-remote-routine","z":"acb2a3ee.cd01c","name":" volume up","account":"456d39e7.429548","routineNode":{"type":"volume","payload":{"value":{"type":"num","value":"10"},"mode":{"type":"str","value":"add"},"devices":["G090U50783961GMV"]}},"x":570,"y":2440,"wires":[[]]},{"id":"5359b3ce.b6091c","type":"function","z":"acb2a3ee.cd01c","name":" volume down Event 3002","func":"event = msg.payload.event.event;\nid = msg.payload.event.id\n\nif (event == 3002 && id == 'tradfri_fernbedienung') {\n     return [msg, null];\n     \n} else {\n   return null;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":370,"y":2520,"wires":[["13fcebc6.31c674"]]},{"id":"13fcebc6.31c674","type":"alexa-remote-routine","z":"acb2a3ee.cd01c","name":" volume down","account":"456d39e7.429548","routineNode":{"type":"volume","payload":{"value":{"type":"num","value":"-10"},"mode":{"type":"str","value":"add"},"devices":["G090U50783961GMV"]}},"x":570,"y":2520,"wires":[[]]},{"id":"9b350392.c5db7","type":"function","z":"acb2a3ee.cd01c","name":"next Event 5002","func":"event = msg.payload.event.event;\nid = msg.payload.event.id\n\nif (event == 5002 && id == 'tradfri_fernbedienung') {\n     return [msg, null];\n     \n} else {\n   return null;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":340,"y":2600,"wires":[["51bdb307.eecf8c"]]},{"id":"51bdb307.eecf8c","type":"alexa-remote-echo","z":"acb2a3ee.cd01c","name":"","account":"456d39e7.429548","config":{"option":"command","value":{"device":{"type":"str","value":"G090U50783961GMV"},"what":"next"}},"x":550,"y":2600,"wires":[[]]},{"id":"8d342af4.dec9f8","type":"function","z":"acb2a3ee.cd01c","name":"previous Event 4002","func":"event = msg.payload.event.event;\nid = msg.payload.event.id\n\nif (event == 4002 && id == 'tradfri_fernbedienung') {\n     return [msg, null];\n     \n} else {\n   return null;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":360,"y":2660,"wires":[["10ccdc59.1c2274"]]},{"id":"10ccdc59.1c2274","type":"alexa-remote-echo","z":"acb2a3ee.cd01c","name":"","account":"456d39e7.429548","config":{"option":"command","value":{"device":{"type":"str","value":"G090U50783961GMV"},"what":"previous"}},"x":560,"y":2660,"wires":[[]]},{"id":"8a62907e.15ede","type":"alexa-remote-routine","z":"acb2a3ee.cd01c","name":"my mix","account":"456d39e7.429548","routineNode":{"type":"music","payload":{"device":{"type":"str","value":"G090U50783961GMV"},"provider":{"type":"str","value":"AMAZON_MUSIC"},"search":{"type":"str","value":"Mein Mix"},"duration":{"type":"num","value":""}}},"x":540,"y":2760,"wires":[[]]},{"id":"217df9c8.714e96","type":"function","z":"acb2a3ee.cd01c","name":"on Event 1002","func":"event = msg.payload.event.event;\nid = msg.payload.event.id\n\nif (event == 1002 && id == 'tradfri_fernbedienung') {\n     return [msg, null];\n     \n} else {\n   return null;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":340,"y":2760,"wires":[["8a62907e.15ede"]]},{"id":"dc4a800c.88fbb","type":"server","name":"Home Assistant"},{"id":"456d39e7.429548","type":"alexa-remote-account","name":"[email protected]","authMethod":"proxy","proxyOwnIp":"192.168.1.33","proxyPort":"3456","cookieFile":"\\config\\node-red","refreshInterval":"3","alexaServiceHost":"layla.amazon.de","amazonPage":"amazon.de","acceptLanguage":"de-DE","userAgent":"","useWsMqtt":"on","autoInit":"on"}]