Send value to a fake sensor

I want to make a “fake” sensor so that I can send values to it with automations. For example when I run an automation that sends IR signals to my airconditioner (in this case I set the temperature to 21C if the temp in the livingroom is below 20C in the morning)

I want to know the latest state of temperature that the airconditioner has received so that I can place it on my dashboard. Is it possible?

My automation looks like this at the moment:

  alias: 0400 Värmepump 21C
  - at: 04:00:00
    platform: time
  - below: '21'
    condition: numeric_state
    entity_id: sensor.vardagsrum_temperature
  - data:
      packet: JgAGAW01DwwPDA8nEAsQJw8MDwwPDBAmECcPDUAAA==
    service: switch.broadlink_send_packet_192_168_1_87

An Input Number is typically used for this type of thing. If you don’t want the user to be able to change the value via the UI, then you would typically not show this entity in the UI (hide it or just don’t add it to the UI), and then you could create a Template Sensor that takes on its value that you would show in the UI.


ah I see, I’ll give this a go tomorrow, thanks! :slight_smile:

This worked flawlessly!

first the input_number:

    name: fujitsu
    min: 10
    max: 30
    step: 1
    mode: box

then made it a sensor

  - platform: template
        friendly_name: Värmepump
        unit_of_measurement: 'C'
        value_template: >
          {{ states('') }}

this is ideal for situations when you use IR signals and want some kind of display for current status


necro… 'cause this awesome little tip is saving me from having to spend hours reprogramming my esphome devices and node-red to get rid of mqtt subscriptions. I was having HA mqtt publish the number of an mp3 file to play when certain states changed (automated through node-red). The esphome devices would play the file associated with that #. This required mqtt subscriptions for all these devices to get those file #'s… not ideal when I’m using the esphome API for everything else.

I initially thought getting rid of mqtt on these devices would require setting up a very complicated template sensor using yaml in HA; basically an entity that would change to a number depending on which from a list of state changes happened last. This would look like a page or 2 filled with if statements. So I was looking for something like input_boolean: which I am already familiar with, but that can handle integers.

input_number: is perfect! After adding an input_number entity, all I have to do is change a handful of nodered mqtt nodes to service call nodes, and change the esphome devices to use homeassistant: sensors instead of mqtt sensors… done. It means I also can still keep all my automations in nodered, and clearly see/adjust my automations like before.