From 0b371833e9ef68fd891fac65a657d8e38b5b3fad Mon Sep 17 00:00:00 2001 From: makefu Date: Sun, 19 Apr 2020 21:24:52 +0200 Subject: ma ham: add the_playlist --- makefu/2configs/ham/multi/the_playlist.nix | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 makefu/2configs/ham/multi/the_playlist.nix (limited to 'makefu/2configs/ham/multi/the_playlist.nix') diff --git a/makefu/2configs/ham/multi/the_playlist.nix b/makefu/2configs/ham/multi/the_playlist.nix new file mode 100644 index 000000000..aa5ce85dc --- /dev/null +++ b/makefu/2configs/ham/multi/the_playlist.nix @@ -0,0 +1,26 @@ +{ + sensor = [ + { platform = "rest"; + name = "pl"; + resource = "http://prism.r:8001/current"; + scan_interval = 30; + json_attributes = [ "name" "filename" "youtube" ]; + } + { platform = "template"; + sensors = { + the_playlist_song = { + friendly_name = "Current Song"; + value_template = ''{{ states.sensor.pl.attributes['name'] }}''; + }; + the_playlist_url = { + friendly_name = "Song Youtube URL"; + value_template = ''{{ states.sensor.pl.attributes['youtube'] }}''; + }; + the_playlist_filename = { + friendly_name = "Song Filename"; + value_template = ''{{ states.sensor.pl.attributes['filename'] }}''; + }; + }; + } + ]; +} -- cgit v1.2.3 From 8fb99675fb4e813accee6c3258160f6cb7059cb8 Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 21 Apr 2020 21:35:59 +0200 Subject: ma ham/the_playlist: init --- makefu/2configs/ham/multi/the_playlist.nix | 57 ++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'makefu/2configs/ham/multi/the_playlist.nix') diff --git a/makefu/2configs/ham/multi/the_playlist.nix b/makefu/2configs/ham/multi/the_playlist.nix index aa5ce85dc..ad090938c 100644 --- a/makefu/2configs/ham/multi/the_playlist.nix +++ b/makefu/2configs/ham/multi/the_playlist.nix @@ -1,9 +1,66 @@ +# Inputs: +# binary_sensor.playlist_button_good +# binary_sensor.playlist_button_bad + +# outputs +# rest_command +# automation +# sensor { + rest_command = { + good_song = { + url = "http://prism.r:8001/good"; + method = "POST"; + }; + bad_song = { + url = "http://prism.r:8001/skip"; + method = "POST"; + }; + }; + automation = [ + { + alias = "playlist song publish"; + trigger = { + #platform = "event"; + #event_data.entity_id = "sensor.the_playlist_song"; + platform = "state"; + entity_id = "sensor.the_playlist_song"; + }; + action = { + service = "mqtt.publish"; + data = { + topic = "/ham/the_playlist/song"; + payload_template = "{{ states.sensor.the_playlist_song.state }}"; + }; + }; + } + { + alias = "playlist upvote on button"; + trigger = { + platform = "state"; + entity_id = "binary_sensor.playlist_button_good"; + from = "off"; + to = "on"; + }; + action.service = "rest_command.good_song"; + } + { + alias = "playlist downvote on button"; + trigger = { + platform = "state"; + entity_id = "binary_sensor.playlist_button_bad"; + from = "off"; + to = "on"; + }; + action.service = "rest_command.bad_song"; + } + ]; sensor = [ { platform = "rest"; name = "pl"; resource = "http://prism.r:8001/current"; scan_interval = 30; + value_template = "1"; json_attributes = [ "name" "filename" "youtube" ]; } { platform = "template"; -- cgit v1.2.3