Change device status from 'home' to 'online'

i have a printer listed via NMAP and it says home , but i would rather say online

this is my sensor template setup

sensor:
platform: template
sensors:
device_tracker.Canon:
value_template: ‘{%- if is_state(“device_tracker.Canon”, “home”) %} Online {% else %} Offline {%- endif %}’

The printer still says its “Home”

any ideas ?

Ta

LeeB

1 Like

Try…

sensor:
  platform: template
  sensors:
    canon:
      value_template:  '{% if is_state("device_tracker.Canon", "home") %} Online {% else %} Offline {%- endif %}'

This will create a new sensor; sensor.canon and the state of this sensor will be either Online or Offline depending on the state of device_tracker.Canon

2 Likes

That’s exactly what I did for all my devices which are stationary. +1

Cheers

I used Connected and Disconnected, to all my wireless devices.

hi masterkenobi

i have just tried this … when i checked the current entities , there is no sensor.canon listed

my sensor…
sensor:
platform: template
sensors:
Canon1:
value_template: ‘{%- if is_state(“device_tracker.canon”, “home”) %} Online {% else %} Offline {%- endif %}’

have i done anything wrong ?
i’ve tried to display sensor.canon1 , but no luck

how do you display the sensor ?

Regards

Lee berry

Please use the Preformatted text to make your code easier to read.

sorry im new to this

sensor:
  platform: template
  sensors:
    Canon1:
      value_template: '{%- if is_state("device_tracker.canon", "home") %} Online {% else %} Offline  {%- endif %}'

i get the following error !!
have no idea what it means

Invalid config for [sensor.template]: expected a dictionary for dictionary value @ data['sensors']['canon1']. Got None
expected a dictionary for dictionary value @ data['sensors']['value_template']. Got '{%- if is_state("device_tracker.canon", "home") %} Online {% else %} Offline  {%- endif %}'

finally got it working

platform: template
sensors:
  kodi:
    value_template: '{% if is_state("device_tracker.kodi", "home") %}online{% else %}offline{% endif %}'
    friendly_name: 'kodi'
  canon:
    value_template: '{% if is_state("device_tracker.Canon", "home") %}online{% else %}offline{% endif %}'
    friendly_name: 'Canon Printer'
  saturn:
    value_template: '{% if is_state("device_tracker.PCSaturn", "home") %}online{% else %}offline{% endif %}'
    friendly_name: 'Saturn'
  mercury:
    value_template: '{% if is_state("device_tracker.PCMercury", "home") %}online{% else %}offline{% endif %}'
    friendly_name: 'Mercury'
  xbox:
    value_template: '{% if is_state("device_tracker.Xbox", "home") %}online{% else %}offline{% endif %}'
    friendly_name: 'Xbox'
3 Likes

Are you getting a lot entries into your log after switching to the template sensors @leeb98 ?

none at all … just orvibo s20 issues

or do you mean in the logbook ? yes

is it also possible to change the color for the state online, offline in the same command?