enkama / hass-variables

Home Assistant variables component
89 stars 12 forks source link

Not compatible with device class, but class seems to be the same #97

Closed Creat1veM1nd closed 9 months ago

Creat1veM1nd commented 9 months ago

Hello,

not sure if I did something wrong or if I hit a bug.

I want to copy the value of the total of energy my solar panels produced at a day into a variable I can work with later. So I created a variable, fitting the options to the variable of my solar panels.

Options of source (sensor.solar_yieldday | 118)

device_class: energy 
state_class: total_increasing
unit_of_measurement: Wh
friendly_name: Production today

Settings for target (sensor.solar_yieldday_history | unknown)

device_class: energy
state_class: total_increasing
unit_of_measurement: Wh
icon: mdi:lightning-bolt-outline
friendly_name: Production today Copy

However, when running a script, which copies the value, I get this: The value entered is not compatible with the selected device_class: energy. Expected: number. Value: sensor.solar_yieldday

I can not find "number" in device class and the value 118 (see above) for sensor.solar_yieldday seems to be a number. I tried different setting for my variable, but with no luck. So I am stuck and need some help.

Here is my automation (maybe I set something wrong ?)

alias: Save Production today
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.solar_producing
    from: "on"
    to: "off"
condition: []
action:
  - service: variable.update_sensor
    data:
      replace_attributes: false
      value: sensor.solar_yieldday
    target:
      entity_id: sensor.solar_yieldday_history
mode: single

Thanks for any help!

Creat1veM1nd commented 9 months ago

Not sure, if it is the right way, but with that value: "{{states('sensor.solar_yieldday')}}"

instead of value: sensor.solar_yieldday

I got it working.

Snuffy2 commented 9 months ago

Yes, value: "{{states('sensor.solar_yieldday')}}" is the correct way to do it. Glad you got it sorted out.

Creat1veM1nd commented 9 months ago

Thanks for the feedback!