Custom entity help

Dear Forum

I im having a hard time to get this custom entity working. Just new to HA and no coding experience.

I have made this code and put in my configuration.yaml to create a new entity that tracks daily costs of electricity.

template:

  • sensor:
    • name: “Nydaglig pris”
      unique_id: “dagligpris”
      state: >
      {{ states(‘sensor.elmaler_energy_daily’) * states(‘sensor.energi_data_service’) }}

No error from studio code server, and the sensor show up under entities.
But the data is unavalible for some reason.

Energi data service current electricity price in DKK (Updates hourly) and sensor_elmaler_daily is daily consumtion in kWh.

Please send help.

I think you need to include floats for your two sensor values, otherwise you’re trying to multiply strings.

Please format your code as pre-formatted text (</> in the cogwheel toolbar menu).

Hi aheju,

I think Jack nailed it, but test it in Open your Home Assistant instance and show your template developer tools.

1 Like