Customise state i.e. change Home to On-line and Away to Off-line

I have some Wifi AP entities that Are reporting in the dashboard as “Home”. I would like this to reflect as “On-line” and then when they drop off, as On-line. They are being picket up via the ASUSWRT integration.

I am guess that this is done using the YAML editor but I am not sure what the code should be.

In customize.yaml

binary_sensor.your_sensor: # change this
  device_class: connectivity
binary_sensor.your_other_sensor: # and change this
  device_class: connectivity

Then restart home assistant. You can reload “Location ans Customizations” instead but the sensors wont change until they change state.

I am still doing something wrong:

configuration.yaml looks as below:

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

homeassistant:
  customize: !include customize.yaml

http:
  ssl_certificate: /ssl/fullchain.pem
  ssl_key: //ssl/privkey.pem
  ip_ban_enabled: true
  login_attempts_threshold: 5

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

# Example configuration.yaml entry for the Telegram Bot
telegram_bot:
  - platform: polling
    api_key: !secret telegram_api_key
    allowed_chat_ids:
      - !secret telegram_chat_id1

customize.yaml

device_tracker.downstairs: 
  device_class: connectivity
device_tracker.upstairs: 
  device_class: connectivity

where “device_tracker.location” is the entity ID.

I rebooted my server and they are still showing as “Home”.

If I understand https://www.home-assistant.io/docs/configuration/customizing-devices/ correctly, device_tracker is not supported by device_class.

Correct, device classes are only applicable to binary_sensors or sensors (see my example above).

The only solution is to make a binary template sensor for each tracker. e.g.

template:
  - binary_sensor:
      - name: "Downstairs"
        state: "{{ is_state('device_tracker.downstairs', 'home' }}"
        device_class: connectivity
      - name: "Upstairs"
        state: "{{ is_state('device_tracker.upstairs', 'home' }}"
        device_class: connectivity

Awesome, many thanks :slight_smile:

state: “{{ is_state(‘device_tracker.downstairs’, ‘home’ )}}”

Just had to add the one round bracket and it worked like a charm… heaps still to learn but I am not getting a feel for how it works.

Oops. Sorry about that.