Question 2: How can I make a switch which will set the input to PS5? And ‘ON’ and ‘OFF’ states of the switch will be checked from first sensor (HDFury Diva Status)
For reference, attached is my hdfury.yaml package file for my VRROOM. To use, change the hdfury.home.lan to your IP or hostname, and update the options in the input_select.hdfury to names you prefer. I keep all automations that use this in separate file (like auto-switching HDMI to XBOX when the XBOX is turned on).
---
# see https://community.home-assistant.io/t/hdfury-sensors-and-switches/574112/2
#
# Terminology used below:
# Source = friendly name of the source selected
# Input = numeric id for the HDMI port representing the source
# NOTE: All N HDMI inputs must be listed in the order of how they are physically plugged in
input_select:
hdfury:
name: 'HDFury Source'
options:
- FireTV # HDMI 0
- XBOX # HDMI 1
- Nintendo # HDMI 2
- HiFiBerry # HDMI 3
icon: 'mdi:hdmi-port'
sensor:
- platform: 'rest'
name: 'HDFury Status' # current status from the HDFury device
resource: 'http://hdfury.home.lan/ssi/infopage.ssi'
value_template: '{{ value_json.portseltx0}}'
json_attributes:
- portseltx0
- RX0
- RX1
- TX0
- TX1
- AUD0
- AUD1
- AUDOUT
- SINK0
- SINK1
scan_interval: '00:01'
template:
- sensor:
- name: 'HDFury Source' # friendly name for source HDFury is currently set to
unique_id: 'd4301eef-fec3-4bb1-a41e-ede4dc93c5d3'
icon: 'mdi:hdmi-port'
state: >
{{ state_attr('input_select.hdfury','options')[ states('sensor.hdfury_status') | int(0) ] }}
- name: 'HDFury Input Desired' # index for the selected source in the option list
unique_id: '8a40fe97-9778-41dd-bebd-6da8974f6dab'
icon: 'mdi:hdmi-port'
state: >
{{ state_attr('input_select.hdfury','options').index(states('input_select.hdfury')) | int(0) }}
- binary_sensor:
# NOTE: Unfortunately, the HDFury VRROOM takes 30+ seconds for it to detect there is no signal
# after switching an input.
- name: 'HDFury Signal Detected'
icon: 'mdi:hdmi-port'
device_class: plug
state: >-
{% set x = state_attr('sensor.hdfury_status', 'RX0') %}
{{ not 'no signal' in x }} # NOTE: HDFury currently returns space prefix
rest_command:
hdfury_select_input:
url: 'http://{{ host }}/cmd?insel={{ input }}%204'
method: 'GET'
script:
change_hdfury_input:
description: 'Change HDFury HDMI Input'
variables:
input: "{{ states('sensor.hdfury_input_desired') }}" # default value
sequence:
- service: rest_command.hdfury_select_input
data:
host: hdfury.home.lan
input: '{{ input }}'
- repeat: # force update the HDFury status
count: 3
sequence:
- delay:
milliseconds: 250
- service: homeassistant.update_entity
data: {}
target:
entity_id: sensor.hdfury_status
automation:
- alias: 'HDFury Source Update'
description: 'Change HDFury HDMI input whenever user changes source'
trigger:
- platform: state
entity_id: input_select.hdfury
action:
- service: script.change_hdfury_input
- alias: 'HDFury Reset Input to HDMI 0'
description: 'Reset HDFury input to HDMI 0 (daily or 30 seconds of no signal)'
trigger:
- platform: time
at: '04:00:00'
- platform: state
entity_id: binary_sensor.hdfury_signal_detected
to: 'off'
for:
seconds: 15
action:
- service: script.change_hdfury_input
data:
input: 0