How to forward a sensor value to a mediator sensor or input_number

Hi there,

I’m genuinely sorry if this is out there, I have read a lot of stuff but all config setups I try don’t seem to work.

Real world scenario is: I have a new smart meter and it’s all connected up. I have to point all my plugs to use the sensor’s value for price.

But what if I move house? Or get a different smart meter interface? I’d have to update all my plugs to point to the new device, one by one.

I’d rather point everything to some kind of variable that in turn I can link up to the smart meter’s value.

This is one example, but this scenario is something I’d like to figure out how to achieve in general.

Can I have an input_number mediate the value of my sensor.electricity_price_per_kwh? Or perhaps another template sensor?

I’ve tried various examples and reloaded HA config, but nothing appears in the entities list.

Here’s the last few things I tried (in configuration.yaml):

input_number:
  kwhprice:
    name: "Electricity - price per kWh"
    data_template:
      value: "{{ states('sensor.electricity_price_per_kwh') }}"
    unit_of_measurement: "GBP/kWh"
    mode: box
template:
    sensor:
      - platform: template
        sensors:
          electricity_price_per_hour:
            name: "Electricity: price per kWh"
            friendly_name: "Electricity: price per kWh"
            unit_of_measurement: "GBP/kWh"
            value_template: >
                {{ states('sensor.electricity_price_per_kwh') }}

The configurations validate, but nothing appears in helpers or entities.

Edit: I could have an automation to run on a timer but this would not be live - is there any way to have something act as a mediator for config abstraction or is that not a thing in HA?

Many thanks in advance!

Are those code snippets from ChatGPT?! The template sensor is a mix of modern and legacy format.

Read the documentation and follow the formats in there.

If you’re not comfortable in YAML, set up your template sensor in the UI, under Helpers.

What do you mean by “mediate”? Copying?

No, not Chat GPT :joy: It’s probably because my searches yielded results from various points in time.

I use YAML daily in my job as a software developer (DevOps etc.), it’s not YAML I’m unfamiliar with, it’s just getting to grips with HA’s format.

I’ll have a further dig through the docs.

I set one up in the UI, but the sensor has a monetary device class, but the UI doesn’t have such an option and forces me into a selection that doesn’t fit.

When I create it via the UI, I can’t see the YAML, in fact I had to use the VS Code add-on, ignore hidden folders just to find where it’s stored when done via the UI, and it’s not YAML in there. Usually, I’d use the UI, make something, look at the YAML and tweak.

I’ll keep playing around though :slight_smile: