HDHomerun Sensors

I’ve got a sensor of sorts using scrape. I use it so that ansible doesn’t update plex while something is recording.

2020-02-29 19_20_13-Window

 - platform: scrape
   name: Homerun Channel 0
   resource: http://192.168.xx.xxx/tuners.html
   select: "tr:nth-of-type(1) td:nth-of-type(2)"

 - platform: scrape
   name: Homerun Channel 1
   resource: http://192.168.xx.xxx/tuners.html
   select: "tr:nth-of-type(2) td:nth-of-type(2)"

 - platform: scrape
   name: Homerun Firmware Status
   resource: http://192.168.xx.xxx/system.html
   select: "span"
2 Likes

Hmmm - doesn’t seem to be working for me.

Do you also have to import the files in his custom_components/hdhomerun

So I could get the info I need by using the scrape commands like Stephen mentioned. Still trying to get it to grab info from the actual other way though.

Also how did you figure out this command?

"tr:nth-of-type(2) td:nth-of-type(2)"

It took some trial and error if I recall but I think I looked through beautifulsoups documentation which is the python module HA uses

How would setup a trigger to send out an email if I have a sensor for the firmware.

sensor.hdhr4_2us_firmware_status
state: Up to date

So when state doesn’t equal “Up to date” send email. I’m trying to figure out the equal to part.

  - alias: HDHR4_2 Firmware Check
    trigger:
      - platform: numeric_state
        entity_id: sensor.hdhr4_2us_firmwarwe_status
      
    action:
      service: notify.home_assistant
      data_template:
        title: "HDHR4_2 Firmware available"
        message: "Update available for hdhr4_2 is available"

Also just came across this - https://info.hdhomerun.com/info/http_api

1 Like

I used some REST sensors instead to get this information.

The sensor that pulls the device information.

  platform: rest
  resource: http://<ip_address>/discover.json
  name: HDHomerun1 info
  json_attributes:
    - FriendlyName
    - ModelNumber
    - FirmwareName
    - FirmwareVersion
    - DeviceID
    - DeviceAuth
    - UpgradeAvailable
    - BaseURL
    - LineupURL
    - TunerCount
    - ConditionalAccess
  value_template: 'OK'

And the sensor that tracks what is currently being shown on a given tuner. You have to create a different sensor for each tuner. I had to update to the latest firmware on the device before it showed everything.

  platform: rest
  resource: http://<ip_address>/status.json
  name: HDHomerun1 Tuner 1 status
  json_attributes_path: "$..[?(@.Resource=='tuner0')]"
  json_attributes:
    - Resource
    - VctNumber
    - VctName
    - Frequency
    - SignalStrengthPercent
    - SymbolQualityPercent
    - TargetIP
  value_template: 'OK'

And for the second tuner on the same device

  platform: rest
  resource: http://<ip_address>/status.json
  name: HDHomerun1 Tuner 2 status
  json_attributes_path: "$..[?(@.Resource=='tuner1')]"
  json_attributes:
    - Resource
    - VctNumber
    - VctName
    - Frequency
    - SignalStrengthPercent
    - SymbolQualityPercent
    - TargetIP
  value_template: 'OK'
13 Likes

Amazing. Works perfectly for me without needing to hack about with my Hassio installation. I’ve added these sensors, plus a couple of extra template sensors to get the current channel attribute out and it works perfectly. Thank you.

thank you! I had issues with the custom component but this works great! I modified it to take in the value of the station being broadcast for the recorder otherwise it displays off

sensor:
  - platform: rest
    resource: http://192.168.xxx.xxx/status.json
    name: HDHomerun Tuner 1
    json_attributes_path: "$..[?(@.Resource=='tuner0')]"
    json_attributes:
    - Resource
    - VctNumber
    - VctName
    - Frequency
    - SignalStrengthPercent
    - SymbolQualityPercent
    - TargetIP
    value_template:  >-
      {% if value_json[0].VctName is defined %}
        {{ value_json[0].VctName }}
      {% else %}
        OFF
      {% endif %}
  - platform: rest
    resource: http://192.168.xxx.xxx/status.json
    name: HDHomerun Tuner 2
    json_attributes_path: "$..[?(@.Resource=='tuner1')]"
    json_attributes:
    - Resource
    - VctNumber
    - VctName
    - Frequency
    - SignalStrengthPercent
    - SymbolQualityPercent
    - TargetIP
    value_template: >-
      {% if value_json[1].VctName is defined %}
        {{ value_json[1].VctName }}
      {% else %}
        OFF
      {% endif %}
4 Likes

Great job all! Has anyone created a Lovelace interface for this?

I’m just using a basic entities card, however I’ve downloaded a channels logo pack and customised the icons so it shows the logo of the tuned-to channel

Can you share the code for that please? Would be interesting to see

Here’s the template sensor (one per tuner):

- platform: template
  sensors:
    hdhomerun_tuner_1_channel:
      friendly_name: HDHomeRun Tuner 1 Channel
      entity_id: sensor.hdhomerun_tuner_1_status
      icon_template: >-
          {%- if state_attr('sensor.hdhomerun_tuner_1_status', 'VctName') %}
              mdi:television-classic
          {% else %}
              mdi:television-classic-off
          {%- endif %}
      value_template: "{{ state_attr('sensor.hdhomerun_tuner_1_status', 'VctName') }}"
      entity_picture_template: >-
          {%- if state_attr('sensor.hdhomerun_tuner_1_status', 'VctName') %}
              /local/images/channels/{{ state_attr('sensor.hdhomerun_tuner_1_status', 'VctName') | lower }}.png
          {%- endif %}

The icons themselves are in the www/images/channels folder. I did have to write a powershell script to enumerate through the files and rename/lower-case them.

The entities card is configured as follows:

entities:
  - entity: sensor.hdhomerun_tuner_1_channel
    name: DVB Tuner 1
    secondary_info: last-changed

This is the result:

image

4 Likes

Hi All -
I installed the hdhomerun integration through HACS (https://github.com/burnnat/ha-hdhomerun) & installed the library with
‘apk add libhdhomerun’

HA loads but is endlessly trying to load the component but never completes.
Did anyone else have this issue?

I had that issue every time I updated HA. I ended up going this route, it’s working well for me: (no plugin needed)

sensor:
- platform: scrape
    name: Homerun Channel 0
    resource: http://192.168.1.138/tuners.html
    select: "tr:nth-of-type(1) td:nth-of-type(2)"

  - platform: scrape
    name: Homerun Channel 1
    resource: http://192.168.1.138/tuners.html
    select: "tr:nth-of-type(2) td:nth-of-type(2)"

  - platform: scrape
    name: Homerun Channel 2
    resource: http://192.168.1.138/tuners.html
    select: "tr:nth-of-type(3) td:nth-of-type(2)"

Thanks, @Scope666
The sensor showed up !

1 Like

For anyone in this group still wanting an HACS installable version of the hdhomerun sensor, I’ve forked the one referenced earlier and made it auto-install all dependencies with a restart of HASS, rather than having to go in to do an apk install.

The new repo is here:

2 Likes

Gave this a shot, got this error:

Damn. Back to the drawing board then.
I wonder why my one worked with a completely fresh container then, that’s strange.

1 Like