HDFury sensors and switches

I want to make some switches and sensors for my HDFury Diva.
I managed to get all I needed in a sensor with the following:

sensors:
  - platform: rest
    name: HDFury Diva Status
    resource: http://192.168.1.154/ssi/infopage.ssi
    value_template: "{{ value_json.portseltx0}}"
    json_attributes:
      - TX0
    scan_interval: '00:01'

value template can return 0,1,2 or 3. They represent 4 inputs.

Question 1: how can I show some text as the sensor value instead of the number? eg: PS5 instead of 3, Nvidia Shield Pro instead of 0.

It is possible to change the input of the device by entering the following URLs in the browser

Change to shield: http://192.168.1.154/cmd?insel=0%204
Change to PS5: http://192.168.1.154/cmd?insel=3%204

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)

1 Like

Hi @arifroni
I’m trying to integrate a VRRoom with home assistant. Did you manage to find a good approach for your Diva?
Cheers

Hi @lordhelmet77

I have done the following:

sensors:

sensor:
  - platform: rest
    name: HDFury Diva Status
    resource: http://192.168.1.154/ssi/infopage.ssi
    value_template: "{{ value_json.portseltx0}}"
    json_attributes:
      - portseltx0
      - RX0
      - RX1
      - TX0
      - TX1
      - AUD0
      - AUD1
      - AUDOUT
      - SINK0
      - SINK1
    scan_interval: '00:01'
  - platform: template
    sensors:
      hdfury_diva_source:
        friendly_name: "HDFury Diva Source"
        value_template: >-
          {% if states('sensor.hdfury_diva_status') | float == 0 %}
          Nvidia Shield TV Pro
          {% elif states('sensor.hdfury_diva_status') | float == 1 %}
          Nintendo
          {% elif states('sensor.hdfury_diva_status') | float == 2 %}
          NO IDEA
          {% elif states('sensor.hdfury_diva_status') | float == 3 %}
          PS5
          {% else %}
          Unknown
          {% endif %}

You will need to adjust your json_attributes and value_template from your json response.


To change inputs you need to create rest command (you need to change the URL to your need and devices.):

rest_command:
  input_change_shield:
    url: 'http://192.168.1.154/cmd?insel=0%204'
    method: GET
  input_change_nintendo:
    url: 'http://192.168.1.154/cmd?insel=1%204'
    method: GET
  input_change_ps5:
    url: 'http://192.168.1.154/cmd?insel=3%204'
    method: GET

Then create input buttons from helper for each source. I made 3, because I have 3 sources.

Then you can create an automation like below, to change the input when you press the buttons.

  - alias: '[Livingroom] [HDFury] Source Update'
    id: '1684834826737'
    description: Change HDFury source and update sensor
    trigger:
      - platform: state
        entity_id:
          - input_button.input_shield
        id: input_shield
      - platform: state
        entity_id:
          - input_button.input_ps5
        id: input_ps5
      - platform: state
        entity_id:
          - input_button.input_nintendo
        id: input_nintendo
    condition: []
    action:
      - choose:
          - conditions:
              - condition: trigger
                id: input_shield
            sequence:
              - service: rest_command.input_change_shield
                data: {}
          - conditions:
              - condition: trigger
                id: input_ps5
            sequence:
              - service: rest_command.input_change_ps5
                data: {}
          - conditions:
              - condition: trigger
                id: input_nintendo
            sequence:
              - service: rest_command.input_change_nintendo
                data: {}
      - delay:
          hours: 0
          minutes: 0
          seconds: 2
          milliseconds: 0
      - service: homeassistant.update_entity
        data: {}
        target:
          entity_id: sensor.hdfury_diva_status

Hope it helps. :slight_smile:

5 Likes

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
1 Like

1 Like