Status as On/Off not Home/Not Home

Is it possible to show the state (on/off) for computers/consoles/routers etc that are always home?
Not really useful to show Home/Not Home for these devices.

Did you try the “value_template” - https://home-assistant.io/components/sensor.template/

- platform: template
  switches:
    computer:
      value_template: "{% if is_state('switch.wol', 'on') %}on{% else %}off{% endif %}"
      turn_on:
        service: switch.turn_on
        entity_id: switch.wol
      turn_off:
        service: switch.turn_off
        entity_id: switch.pc
1 Like

I was just reading about it right now via this post

However unless I am missing something it will just always be home because it has detected that it is connected to my router. So just changing the text to be on/off wouldn’t be enough… I’m thinking that i need to see if it is actually on or off (ping maybe). I think that is the link that i am missing…

Yes, I’m using the ping component to check if a machine is up and running or not.

I don’t think you need that - at least I don’t…
So what I mean is, if you base it on your known devices, you can see which devices are home/not home. What that really means is not their physical location but whether or not they are connected to your router. And if they are not connected (so showing not home) then they are off. No need to add a ping to that…

So simple! Thats what i was missing. Thanks

DDK, I turned discovery off so i needed ping.

So… the states were changing but I was still unable to change the name of the states.
I have tried through ping and discovery but neither work so i have obviously still done something wrong.

This in my config file if someone could point out my mistake.

Found some errors and fixed them. I no longer get any errors with below config but still not changing the state name.

homeassistant:
  # Name of the location where Home Assistant is running
  name: Home
  # Location required to calculate the time the sun rises and sets
  latitude: -33.9152560
  longitude: 151.1156200
  # Impacts weather/sunrise data (altitude above sea level in meters)
  elevation: 3
  # metric for Metric, imperial for Imperial
  unit_system: metric
  # Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
  time_zone: Australia/Sydney
  customize:
    # Add an entry for each entity that you want to overwrite.
    device_tracker.tab_s:
      friendly_name: Garys Android Tab 'S'
      icon: mdi:tablet-android
    device_tracker.garys_iphone:
      friendly_name: Garys iPhone
      icon: mdi:cellphone-iphone
    device_tracker.ryansiphone:
      friendly_name: Ryans iPhone
      icon: mdi:cellphone-iphone
    device_tracker.htpc:
      friendly_name: HTPC
      icon: mdi:movie-roll
    device_tracker.nas:
      friendly_name: QNAP
      icon: mdi:harddisk
    device_tracker.xboxsystemos:
      friendly_name: xBox One
      icon: mdi:xbox
    device_tracker.lounge_room_light:
      friendly_name: Lounge Room Light 
      icon: mdi:lightbulb-on-outline
    device_tracker.PS4:
      friendly_name: PS4 
      icon: mdi:playstation

# Show links to resources in log and frontend
# introduction:

# Enables the frontend
frontend:

# Enables configuration UI
config:

http:
  # Uncomment this to add a password (recommended!)
  api_password: !secret api_password
  # Uncomment this if you are using SSL/TLS, running in Docker container, etc.
  # base_url: example.duckdns.org:8123

# Checks for available updates
# Note: This component will send some information about your system to
# the developers to assist with development of Home Assistant.
# For more information, please see:
# https://home-assistant.io/blog/2016/10/25/explaining-the-updater/
updater:
  # Optional, allows Home Assistant developers to focus on popular components.
  include_used_components: true

# Discover some devices automatically
#discovery:

# Allows you to issue voice commands from the frontend in enabled browsers
conversation:

# Enables support for tracking state changes over time
history:

# View all events in a logbook
#logbook:

# Track the sun
sun:

# Logger
#logger:

# Yeelight - Lounge Room
light:
    - platform: yeelight
      devices:
        10.10.0.12:
            name: Lounge Room
            transition: 1000
            use_music_mode: True
            save_on_change: True
        # 192.168.1.13:
            # name: Front Door

# Netgear Router R7000 NightHawk
device_tracker:
  - platform: netgear
    username: !secret netgear_un
    password: !secret netgear_password
    interval_seconds: 10
    consider_home: 0:03:00
    track_new_devices: yes
  - platform: ping
    hosts:
      HTPC: !secret htpc_ip
      Laptop: !secret laptop_ip

# Weather prediction and QNAP
sensor:
  - platform: template
    sensors:
      playstation_sensor:
        value_template: '{% if is_state("device_tracker.ps4", "home") %}online{% else %}offline{% endif %}'
      xbox_sensor:
        value_template: '{% if is_state("device_tracker.xboxsystemos", "home") %}online{% else %}offline{% endif %}'
  - platform: yr
  - platform: moon
  - platform: qnap
    host: !secret qnap_ip
    username: !secret qnap_un
    password: !secret qnap_password
    timeout: 30
    monitored_conditions:
      - status
      - cpu_usage
      - memory_percent_used
      - volume_percentage_used
      - network_tx

# Text to speech
tts:
  - platform: google

group: !include groups.yaml
automation: !include automations.yaml
1 Like

Solved it. For anyone new and wondering the same thing setting up the template means that you need to call it a different way… replace

- device_tracker.xboxsystemos

with

- sensor.xbox_sensor

or whatever you have called the new sensor. It obviously was not updating for me as i was looking at the wrong component… duh…

Notice the known device device_tracker.kyloren in the code I sent you. So no it will not be allways home.