SolarEdge Automation

I am trying to set up an automation based on my grid power. Basically…if I export enough I want to turn on some devices. I have the Solaredge integration setup and can see all the values but…I get an error in the automation.

Value cannot be processed as a number: <state sensor.solaredge_grid_power=0.65; status=Active, flow=import, unit_of_measurement=kW, friendly_name=solaredge (Grid Power), icon=mdi:power-plug, device_class=power @ 2020-12-08T13:12:31.818950+01:00> (Offending entity: state("sensor.solaredge_grid_power"))

This is the sensor:
sensor

So my trigger should be: if value is lower than -1 it should fire…

Any ideas?

How does your current automation look like?

- id: '1607169830764'
  alias: Airco An
  description: ''
  trigger:
  - platform: numeric_state
    below: '-1000'
    entity_id: sensor.solaredge_imported_power
  condition:
  - condition: device
    device_id: f8b1ed21127cd75a2cbeca607cf2724d
    domain: climate
    entity_id: climate.33031685500291bdc81d
    type: is_hvac_mode
    hvac_mode: 'off'
  action:
  - device_id: f8b1ed21127cd75a2cbeca607cf2724d
    domain: climate
    entity_id: climate.33031685500291bdc81d
    type: set_hvac_mode
    hvac_mode: heat
  mode: single```

This may very well be just a startup error. Home Assistant tries to compare unavailable to -1000, which will work once the state changes from unavailable or unknown (String) to any number.
I guess you could change the below: '-1000' to a higher number so the A/C kicks in, it should work.

I have similar log enties;

Logger: homeassistant.components.template.cover
Source: components/template/cover.py:281
Integration: template (documentation, issues)
First occurred: December 6, 2020, 7:20:00 PM (1 occurrences)
Last logged: December 6, 2020, 7:20:00 PM

could not convert string to float: 'unknown' 

But once the REST integration reaches out to retrieve the value, the error becomes irrelevant.

Well… It also didn’t trigger it… Tried that…

And…also when I activate the automation later, meaning when values are available, it gives me the same error in the log. So that is not it…

What happens when you paste this into the Template Editor in the developer tools?

State: {{ states('sensor.solaredge_grid_power') }}
State x2: {{ states('sensor.solaredge_grid_power') * 2 }}
State as float: {{ states('sensor.solaredge_grid_power') | float }}
condition1:  {{ states('sensor.solaredge_grid_power') < 100 }}
condition2: {{ states('sensor.solaredge_grid_power') > 100 }}
float condition1: {{ (states('sensor.solaredge_grid_power') | float ) > 100 }}
float condition2: {{ (states('sensor.solaredge_grid_power') | float ) < 100 }}

Also make sure it’s not unavailable more often than not - check the entity history to make sure it’s not unavailable or sth. similar

TypeError: '<' not supported between instances of 'str' and 'int

So it seems it gives the value as a string, I do know my way around coding in .NET but…how do I convert the string to a number within Home Assistant and the automation…? (I assume there is a way)

Okay, so it’s a string, that’ll be easy enough.
The screenshot you’ve shared includes sensor.solaredge_grid_power while your automation uses sensor.solaredge_imported_power, is this really the one you want to use? Just making sure.
If so, you can either set up a template sensor like this:

sensor:
  - platform: template
    sensors:
      solar_energy:
        friendly_name: "solar energy"
        unit_of_measurement: 'kW'
        value_template: "{{ states(sensor.solaredge_grid_power') | float }}"

And use this sensor as your entity_id in your trigger, or use a template trigger that includes a float conversion:

- id: '1607169830764'
  alias: Airco An
  description: ''
  trigger:
  - platform: template
    value_template: "{{ (states('sensor.solaredge_imported_power') | float ) < -1000 }}"
  condition:
  - condition: device
    device_id: f8b1ed21127cd75a2cbeca607cf2724d
    domain: climate
    entity_id: climate.33031685500291bdc81d
    type: is_hvac_mode
    hvac_mode: 'off'
  action:
  - device_id: f8b1ed21127cd75a2cbeca607cf2724d
    domain: climate
    entity_id: climate.33031685500291bdc81d
    type: set_hvac_mode
    hvac_mode: heat
  mode: single```

That sounds like the answer I needed. With your explanation, the world of HASS has opened a bit more to me…:wink:

I have opted for the first, so created it all in the configuration.yaml and changed my automation to use that. Now rebooted everything and waiting if it will trigger. Since the values are only read every 15 or 30 minutes (not sure) I assume something should happen in the next half hour… I will update here.

EDIT: and yes, I messed around with the automations, trying to use different sensors, that is why there is a difference between the screenshot and the automation. I am using the grid_power one and check if that value is below this -1 kW (for testing I set it to be below 10 kW so it should work).
One thing I noticed…while editing the automations.yaml I also deleted one of my test automations. Now unfortunately it shows up in the UI, but I cannot edit or remove it from there. Seems like kind of an “orphan” and the “reload Automations” option is not available under “server control” anymore"

EDIT2: it works. Only somehow the Condition I wanted to use does not work. I wanted to check for the HVAC Mode being “‘off’” but that prevents the automation from doing anything. If I take the condition out, it works. So…one step further already

1 Like

Nice to hear :slight_smile:Bookmark this page - it’ll go a long way: https://www.home-assistant.io/docs/configuration/templating/

When editing automations in the UI, they get loaded immediately and put into the YAML file.
When editing the YAML file manually, you have to reload. So if you edit manually and then use the UI, your first changes will be overriden.
Hope you get the last issue sorted out as well :slight_smile:
Personally I like to not use device stuff and stick to entities, makes that a lot cleaner in YAML :slight_smile:

Yeah, I understand that. But it somehow now messed up the UI. There is an automation visible which I cannot edit anymore and it is not present in the yaml file. And, as I said, on top of that the button to reload the automations file has disappeared from the UI. I am one of these who get really annoyed by that. And if it had not been for that fact that I made quite a lot of things work today and did NOT make a snapshot before starting this… Well…you get my point. I guess I will revert to an earlier snapshot and just redo what I did today. A second time is always faster, right…:wink:

Thanks again!

EDIT: your tip with not using devices, but stick to entities also did the trick with the condition. Checking the entity state is more reliable I guess. So now…all works as I want. Thanks for the help…fantastic community here!

1 Like

And even sorted out the UI issue. Deleting an unavailable entity from the developer tools and a reboot did the trick.

Now I can sleep in peace

Hi @Remko

Would you kindly post your final configuration? I used the template trigger float and it is still not triggering:

```{{ (states(‘sensor.solaredge_grid_power’) | float ) < -0.3 }}`

Thank you in advance

Nevermind, it works :slight_smile: There was a comma too much in the beginning and 1 too little in the end