Flow that intercepts Christmas music that gets played too early

I conceded on my wife putting up the tree in the middle of November. But we will NOT be listening to Christmas songs before Thanksgiving.

EDITED TTS to remove adult language.

  - binary_sensor:
    - unique_id: christmas_music_playing
      name: Christmas Music Playing
      icon: mdi:speaker-play
      state: >
        {% set title = state_attr('media_player.sonos_kitchen', 'media_title') %}
        {% set album = state_attr('media_player.sonos_kitchen', 'media_album_name') %}
        {% set playlist = state_attr('media_player.sonos_kitchen', 'media_playlist') %}
        {% set player = is_state('media_player.sonos_kitchen', 'playing') %}
        {{ ("Christmas" in title or "Christmas" in album or "Christmas" in playlist or "Holiday" in title or "Holiday" in album or "Holiday" in playlist) and player }}

Flow:

[{"id":"d4d10811864a1c0c","type":"group","z":"eb3cbe54.bd558","name":"GRINCH: Stop Christmas Music from Playing before Thanksgiving","style":{"stroke":"#ff0000","fill":"#92d04f","fill-opacity":"0.5","label":true,"color":"#000000"},"nodes":["853826fe06691f49","6a2127a295e12e79","b94341dd4bc0080c","70a8b852e6a09fad"],"x":754,"y":2079,"w":792,"h":82},{"id":"853826fe06691f49","type":"function","z":"eb3cbe54.bd558","g":"d4d10811864a1c0c","name":"Block Song?","func":"const today = new Date();\nconst day = Number(today.getDate());\nconst month = Number(today.getMonth() + 1);\n\nif (month <= 10)\n    msg.payload = \"true\";\nelse if (month == 11 && day <= 28)\n    msg.payload = \"true\";\nelse\n    msg.paylod = \"false\";\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":1110,"y":2120,"wires":[["6a2127a295e12e79"]]},{"id":"6a2127a295e12e79","type":"http request","z":"eb3cbe54.bd558","g":"d4d10811864a1c0c","name":"Cut it Out","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://10.0.0.30:5005/kitchen/say/It's too early for that nonsense./45","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":1280,"y":2120,"wires":[["70a8b852e6a09fad"]]},{"id":"b94341dd4bc0080c","type":"server-state-changed","z":"eb3cbe54.bd558","g":"d4d10811864a1c0c","name":"Christmas Music Playing","server":"296c0678.b5f9ca","version":6,"outputs":2,"exposeAsEntityConfig":"","entities":{"entity":["binary_sensor.christmas_music_playing"],"substring":[],"regex":[]},"outputInitially":false,"stateType":"habool","ifState":"true","ifStateType":"bool","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"5","forType":"num","forUnits":"seconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"true","valueType":"bool"}],"x":890,"y":2120,"wires":[["853826fe06691f49"],[]]},{"id":"70a8b852e6a09fad","type":"http request","z":"eb3cbe54.bd558","g":"d4d10811864a1c0c","name":"Audio Pause","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://10.0.0.30:5005/kitchen/pause/","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":1450,"y":2120,"wires":[[]]},{"id":"296c0678.b5f9ca","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]

image

2 Likes