From a01c5d325cb016bb658b8e56d81a6cb04b89679f Mon Sep 17 00:00:00 2001 From: Sthope Date: Mon, 1 Apr 2024 12:25:18 +0200 Subject: [PATCH] Add HA_SmartTV.yml --- HA_SmartTV.yml | 153 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 HA_SmartTV.yml diff --git a/HA_SmartTV.yml b/HA_SmartTV.yml new file mode 100644 index 0000000..1dcba6b --- /dev/null +++ b/HA_SmartTV.yml @@ -0,0 +1,153 @@ +media_player: + - platform: universal + name: SMART TV + children: + - media_player.kodi_smarttv + state_template: > + {% if is_state('media_player.kodi_smarttv', 'idle') and is_state('switch.smart_tv_power_switch', 'off') %} + off + {% else %} + {{ states('media_player.kodi_smarttv') }} + {% endif %} + commands: + turn_on: + service: media_player.turn_on + target: + entity_id: media_player.kodi_smarttv + turn_off: + service: media_player.turn_off + target: + entity_id: media_player.kodi_smarttv + attributes: + is_volume_muted: media_player.kodi|is_volume_muted + volume_level: media_player.kodi|volume_level + browse_media_entity: media_player.kodi_smarttv + device_class: tv + unique_id: smarttv_universal + +mqtt: + - switch: + unique_id: smarttv_power_switch + name: "Power Switch" + state_topic: "smarttv/state" + command_topic: "smarttv/command" + payload_on: "power_on" + payload_off: "power_off" + value_template: "{{ value_json.power_state }}" + state_on: "on" + state_off: "off" + icon: mdi:television-classic + device: &smarttv_device + name: "SMARTTV2MQTT" + identifiers: "SMART TV SPNL-6065" + manufacturer: "SMART Technologies" + model: "SPNL-6065" + serial_number: "K012HW21R0559" + + - switch: + unique_id: smarttv_mute_or_unmute + name: "Mute" + state_topic: "smarttv/state" + command_topic: "smarttv/command" + value_template: "{{ value_json.mute }}" + payload_on: "mute" + payload_off: "unmute" + state_on: "on" + state_off: "off" + icon: mdi:volume-off + device: + <<: *smarttv_device + + - number: + unique_id: smarttv_volume + name: "Volume" + command_topic: "smarttv/command" + state_topic: "smarttv/state" + value_template: "{{ value_json.volume }}" + command_template: "SMARTTV_SET_VOLUME={{ value }}" + step: 1 + min: 0 + max: 100 + mode: slider + icon: mdi:volume-high + optimistic: true + device: + <<: *smarttv_device + + - button: + unique_id: smarttv_get_powerstate + name: "get_powerstate" + command_topic: "smarttv/command" + payload_press: "get_powerstate" + device: + <<: *smarttv_device + + - button: + unique_id: smarttv_get_volume + name: "get_volume" + command_topic: "smarttv/command" + payload_press: "get_volume" + device: + <<: *smarttv_device + + - button: + unique_id: smarttv_get_input + name: "get_input" + command_topic: "smarttv/command" + payload_press: "get_input" + device: + <<: *smarttv_device + + - button: + unique_id: smarttv_get_mute + name: "get_mute" + command_topic: "smarttv/command" + payload_press: "get_mute" + device: + <<: *smarttv_device + + - button: + unique_id: smarttv_set_ops_audio + name: "Set OPS Audio" + command_topic: "smarttv/set_tv_audio" + payload_press: "hdmi" + icon: mdi:cast-audio + device: + <<: *smarttv_device + + - button: + unique_id: smarttv_reboot_ops + name: "Reboot OPS" + command_topic: "smarttv/reboot_ops" + payload_press: "reboot_ops" + icon: mdi:restart + device: + <<: *smarttv_device + + - button: + unique_id: smarttv_kodi_fullscreen + name: "Kodi Fullscreen" + command_topic: "smarttv/smarttv_kodi_fullscreen" + payload_press: "smarttv_kodi_fullscreen" + icon: mdi:restart + device: + <<: *smarttv_device + + - select: + unique_id: smarttv_get_mute + name: "Input Select" + command_topic: "smarttv/command" + state_topic: "smarttv/state" + value_template: "{{ value_json.input }}" + icon: mdi:import + command_template: >- + {% if value == "HDMI" %} + "set_input_hdmi" + {% elif value == "OPS" %} + "set_input_ops" + {% endif %} + options: + - "OPS" + - "HDMI" + device: + <<: *smarttv_device \ No newline at end of file