Better looking device tracker

I have all my network devices showing on HA, so that I can check what is online or offline. On those devices I only want to see if they are home or not_home (they will never be in any other state). Having them as normal device_tracker’s does not look very good, so I made a component to automatically create binary sensors from them, and now they look like this:

You can get the component from here: https://raw.githubusercontent.com/abmantis/homeassistant-custom-components/master/binary_sensor/device_tracker_sensor.py

Just create a folder named binary_sensor inside your custom_components folder, and place the component there.

Then configure it as follows:

binary_sensor:
  - platform: device_tracker_sensor
    entities:
      - device_tracker.device_a
      - device_tracker.device_b
      - device_tracker.device_c

The list of entities is the list of device_tracker entities that you would want a binary sensor to be created for.

Special thanks to @pilotak since this is based on his component (https://github.com/pilotak/HomeAssistant-CustomComponents/blob/master/sensor/attributes.py)

27 Likes

This is SUPER awesome! Will you be submitting this to the main branch?

Glad you find it awesome :smiley:
I don’t think it would be accepted, since you can do this with template sensors (but in a much more cumbersome way, since you would have to manually define each one of them). I think that it was @pilotak who submitted his component (which is similar to mine but with a different purpose), and it was rejected because of that reason. But I’ll try to check with the HA devs anyway! :slight_smile:

2 Likes

Can I use any entities or just device trackers only?

Is the code looks for only status ‘on’ and ‘off’? I tried few sensor entities (rf switches) with values ‘on’ and ‘off’ but that didn’t work. I even used zwave aeotec stick in the config.

binary_sensor:
  - platform: device_tracker_sensor
    entities:
      # - sensor.google_wifi_status
      # - sensor.leeoalarmstatus
      # - sensor.hallway_nest_protect_co_status
      # - sensor.hallway_nest_protect_smoke_status
      # - sensor.basement_leeoalarmstatus
      - sensor.rf_switch_one
      - sensor.rf_switch_two
      - sensor.rf_switch_three
      - sensor.rf_switch_four
      - sensor.rf_switch_five
      - zwave.aeotec_zw090_zstick_gen5

Group:

 new_binary_sensors:
  name: Binary Sensor New
  entities:
    # - binary_sensor.device_tracker_basement_leeoalarmstatus
    # - binary_sensor.device_tracker_google_wifi_status
    # - binary_sensor.device_tracker_hallway_nest_protect_co_status
    # - binary_sensor.device_tracker_hallway_nest_protect_smoke_status
    # - binary_sensor.device_tracker_leeoalarmstatus
    - binary_sensor.device_tracker_rf_switch_one
    - binary_sensor.device_tracker_rf_switch_two
    - binary_sensor.device_tracker_rf_switch_three
    - binary_sensor.device_tracker_rf_switch_four
    - binary_sensor.device_tracker_rf_switch_five
    - binary_sensor.device_tracker_aeotec_zw090_zstick_gen5

image

Hey. This is only for device_tracker entities.
For a similar component for other types, check this: https://github.com/pilotak/HomeAssistant-CustomComponents

Hi, It is a great upgrade to an automatic discovery of all devices on your LAN. Can you share the full approach on how you got it implemented like configuration.yaml, folder structure etc to get this fully working.

I can’t do that right know (I’ll try in the next days), but it is pretty simple.
I added all the device_tracker entities to the custom components (as show in the example config). Then I just added the resulting binary_sensor entities to two groups.

nice work!
i think you could make it even better if you would add an option to set the state in the config.
like:

binary_sensor:
  - platform: device_tracker_sensor
    on_state_text: an
    off_state_text: aus  
    entities:
      - device_tracker.device_a
      - device_tracker.device_b
      - device_tracker.device_c

Thanks! Since those are binary sensors, they don’t allow the text to be changed I think (they do allow device classes but their text is fixed for the class).
Using sensors instead of binary_sensors would loose the yellow icon.

sorry, didnt think of that.
i never tried to change the icons in HA, so i didnt know that you only can do that with binary_sensors.

abmantis, thank you for sharing. Implemented and works great!

1 Like

Thank you for this. Though can you help me make it look like your example?

Mine looks like this after implementing it:

You have to put the binary_sensors into groups :wink:

Like this example from my groups.yaml:

Geräte:
- binary_sensor.device_tracker_fritzbox
- binary_sensor.device_tracker_fritzrepeater
- binary_sensor.device_tracker_openmediavault
- binary_sensor.device_tracker_philipstv

Ok, gotta start reading up on groups:) Thanks.

Thanks for putting this together!

Since 64.0, I receive the following error.

https://www.myhomeassistantsite.com:8123/frontend_es5/custom-elements-es5-adapter.js:4:906 NotSupportedError (DOM Exception 9): Cannot define multiple custom elements with the same tag name.

I guess it is related to this custom component script.

I suspect that the cause is related to the the breaking change of the customs component, see https://github.com/home-assistant/home-assistant/pull/12463

That issue is not related to this custom component. The component is working fine on 0.64.

It seems to have solved it itselves. No more errors now.

~This appears to have broken in 0.56.x – all of my devices show as “off”.~ Scratch that; Docker misconfiguration.

is there a way to include wake on lan switch with this?