leeb98
(Lee Berry)
September 9, 2016, 9:10am
1
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
PhyberApex
(Phyber Apex)
September 9, 2016, 12:43pm
3
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.
leeb98
(Lee Berry)
September 12, 2016, 4:25am
5
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.
leeb98
(Lee Berry)
September 12, 2016, 5:55am
7
sorry im new to this
sensor:
platform: template
sensors:
Canon1:
value_template: '{%- if is_state("device_tracker.canon", "home") %} Online {% else %} Offline {%- endif %}'
leeb98
(Lee Berry)
September 12, 2016, 8:22am
8
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 %}'
leeb98
(Lee Berry)
September 17, 2016, 11:41am
9
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
silvrr
October 7, 2016, 2:10am
10
Are you getting a lot entries into your log after switching to the template sensors @leeb98 ?
leeb98
(Lee Berry)
October 7, 2016, 2:37am
11
none at all … just orvibo s20 issues
leeb98
(Lee Berry)
October 7, 2016, 2:38am
12
or do you mean in the logbook ? yes
leenos
(leenos)
January 9, 2020, 11:12am
13
is it also possible to change the color for the state online, offline in the same command?