Binary Sensor PING icon change on state?

Hi

Does anyone have a way round changing the icon depending on the state of a binary sensor PING ?

I have changed the device_class to power.

I have a binary_sensor.yaml and customised.yaml

binary_sensor.lg_tv_status:
  templates: 
  friendly_name: LG TV (Living Room)
  device_class: power
  icon_template: >-
    {% if is_state('binary_sensor.luis_tv_status','On') %}
      mdi:television
    {% else %}
      mdi:television-off
    {% endif %}

Does the code look OK, if not where should the actual code go ?

Thanks

Martyn

Absolutely, NO!
If this should be the ping binary_sensor, take a look here:

If it should be a template binary_sensor, here:

You cannot mix configuration variables from different integrations.

Hi

Sorry, I have the ping separately on the old way I did it and it worked but it created 2 instances of a sensor.

I wanted just 1 instance of the sensor, I was told it was possible but no example was given. Hence me trying.

My Ping is

  - platform: ping
    host: 192.168.0.10
    scan_interval: 30
    name: living_room_tv_status

Thanks

Martyn

Hi

This is my actual code in binary_sensor.yaml is there no actual way to get this together in 1 instance/sensor ?

- platform: template
sensors:
living_room_tv_power:
friendly_name: Living Room TV
icon_template: >
{% if is_state('binary_sensor.living_room_tv_status','on') %} mdi:television
{% else %} mdi:television-off
{% endif %}
device_class: power
value_template: >-
{% if not is_state('binary_sensor.living_room_tv_status', 'off') and not is_state('binary_sensor.living_room_tv_status','unavailable') %}
true
{% endif %} 
- platform: ping
host: 192.168.0.10
scan_interval: 30
name: living_room_tv_status