{ services.home-assistant.extraComponents = [ "ping" "broadlink" "androidtv" "samsungtv" ]; services.home-assistant.config = { binary_sensor = [ { name = "xbox"; platform = "ping"; host = "xbox.cloonar.multimedia"; count = 1; scan_interval = 2; } { name = "ps5"; platform = "ping"; host = "ps5.cloonar.multimedia"; count = 1; scan_interval = 2; } { platform = "template"; sensors = { multimedia_device_on = { friendly_name = "Any multimedia device on"; device_class = "connectivity"; value_template = '' {% if is_state('binary_sensor.ps5', 'on') or is_state('binary_sensor.xbox', 'on') or states('media_player.fire_tv_firetv_living_cloonar_multimedia') != 'off' %} on {% else %} off {% endif %} ''; }; }; } ]; # "automation tv scene" = { # alias = "auto tv scene"; # hide_entity = true; # trigger = { # platform = "event"; # event_type = "button_pressed"; # event_data = { # id = [ 254 235 105 198 ]; # }; # }; # action = { # service_template = "switch.turn_on"; # data_template = { # entity_id = "switch.computer"; # }; # }; # }; # "automation beamer switch" = { # alias = "auto beamer scene"; # hide_entity = true; # trigger = { # platform = "state"; # entity_id = "sensor.computer_power"; # }; # condition = { # condition = "and"; # conditions = [ # { # condition = "numeric_state"; # entity_id = "sensor.computer_power"; # below = 15; # } # "{{ (as_timestamp(now()) - as_timestamp(states.switch.computer.last_changed)) > 300 }}" # ]; # }; # action = { # service = "switch.turn_off"; # target = { # entity_id = [ "switch.computer" ]; # }; # }; # }; "automation xbox on" = { alias = "xbox on"; hide_entity = true; trigger = { platform = "state"; entity_id = "binary_sensor.xbox"; to = "on"; }; action = [ { service = "media_player.select_source"; target = { entity_id = "media_player.marantz_sr6015"; }; data = { source = "Xbox"; }; } # { # delay = 5; # } # { # service = "denonavr.get_command"; # target = { # entity_id = "media_player.marantz_sr6015"; # }; # data = { # command = "/goform/formiPhoneAppDirect.xml?PWSTANDBY"; # }; # } ]; }; "automation firetv on" = { alias = "firetv on"; hide_entity = true; trigger = { platform = "state"; entity_id = "media_player.fire_tv_firetv_living_cloonar_multimedia"; from = "off"; }; action = [ { service = "denonavr.get_command"; target = { entity_id = "media_player.marantz_sr6015"; }; data = { command = "/goform/formiPhoneAppDirect.xml?SIMPLAY"; }; } ]; }; "automation ps5 on" = { alias = "ps5 on"; hide_entity = true; trigger = { platform = "state"; entity_id = "binary_sensor.ps5"; to = "on"; }; action = [ { service = "denonavr.get_command"; target = { entity_id = "media_player.marantz_sr6015"; }; data = { command = "/goform/formiPhoneAppDirect.xml?SIBD"; }; } ]; }; "automation all multimedia off" = { alias = "all multimedia off"; trigger = { platform = "state"; entity_id = "binary_sensor.multimedia_device_on"; to = "off"; }; action = [ { service = "media_player.turn_off"; target = { entity_id = "media_player.android_tv_metz_cloonar_multimedia"; }; } { service = "denonavr.get_command"; target = { entity_id = "media_player.marantz_sr6015"; }; data = { command = "/goform/formiPhoneAppDirect.xml?PWSTANDBY"; }; } ]; }; "automation all_multimedia_on" = { alias = "all multimedia on"; trigger = { platform = "state"; entity_id = "binary_sensor.multimedia_device_on"; to = "on"; }; condition = { condition = "or"; conditions = [ { condition = "state"; entity_id = "media_player.android_tv_metz_cloonar_multimedia"; state = "off"; } { condition = "state"; entity_id = "media_player.android_tv_metz_cloonar_multimedia"; state = "unavailable"; } ]; }; action = [ { choose = [ { conditions = [ { condition = "state"; entity_id = "media_player.android_tv_metz_cloonar_multimedia"; state = "off"; } ]; sequence = [ { service = "media_player.turn_on"; target = { entity_id = "media_player.android_tv_metz_cloonar_multimedia"; }; } ]; } { conditions = [ { condition = "state"; entity_id = "media_player.android_tv_metz_cloonar_multimedia"; state = "unavailable"; } ]; sequence = [ { service = "remote.send_command"; target = { entity_id = "remote.rmproplus"; }; data = { num_repeats = 1; delay_secs = 0.4; hold_secs = 0; command = "b64:JgBOAJaSFREVNRU2FTUVERURFRAVERURFTUVNhU1FREVERUQFREVERUQFTYVNRURFREVEBURFTYVNRURFRAVNhU1FTYVNRUABfmWkhURFQANBQAAAAAAAAAAAAA="; }; } ]; } ]; } { delay = 5; } { service = "androidtv.adb_command"; target = { entity_id = "media_player.android_tv_metz_cloonar_multimedia"; }; data = { command = "adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.mediatek.tvinput%2F.hdmi.HDMIInputService%2FHDMI100004"; }; } ]; }; # "automation multimedia input" = { # hide_entity = true; # trigger = { # platform = "state"; # entity_id = "sensor.computer_power"; # }; # condition = { # condition = "and"; # conditions = [ # { # condition = "numeric_state"; # entity_id = "sensor.computer_power"; # below = 15; # } # "{{ (as_timestamp(now()) - as_timestamp(states.switch.computer.last_changed)) > 300 }}" # ]; # }; # action = { # service = "switch.turn_off"; # target = { # entity_id = [ "switch.computer" ]; # }; # }; # }; }; }