Fake light entity

Hello everyone,

I did not (yet) put a smart bulb in my bathroom.
Nevertheless, I can know exactly when the light is on as it is on the same circuit as a Sonos One.

So, when the Sonos is unavailable, the light is off, when it is available, you got the thing …

My question is then, is there any (elegant) way to visualize a sensor.bathroom entity that doesn’t exists but that I could create as a “template” with device_class: light or something based on the Sonos status, in lovelace? Maybe a mqtt object could work (I have a broker available and can use Node-RED to generate a message)?

Any smart idea?

Thank you,

Olivier

Edit: I know how to do it as a binary_sensor but I’d like it to show as a light bulb with all my other “real” lights.

1 Like

You could define a mqtt light/

Followed the link provided by @Burningstone and it worked well.
Here is my configuration for who might be interested.

light:
  - platform: template
    lights:
      bathroom:
        friendly_name: "Bathroom"
        value_template: >-
          {% if is_state('media_player.bathroom', 'unavailable') %}
            off
          {% else %}
            on
          {% endif %}
        turn_on:
          service: media_player.turn_on
          target:
            entity_id: media_player.bathroom
        turn_off:
          service: media_player.turn_on
          target:
            entity_id: media_player.bathroom

And yes, I’ve put stupid service calls for turn_on/off as it is mandatory but there is nothing to actually control the light.

2 Likes