when sensor.solarnet_power_grid changes then if input_number.tesla_power_load_helper is more than sensor.solarnet_power_photovoltaics then set input_number.tesla_solar_to_grid_helper to 0
but if input_number.tesla_power_load_helper is less than sensor.solarnet_power_photovoltaics then input_number.tesla_solar_to_grid_helper to the state of sensor.solarnet_power_photovoltaics - input_number.tesla_power_load_helper
ive tried with chat gpt but it keeps throwing errors and has different code each time
Don’t. It produces confident gibberish and if you can’t spot this it will only make you more confused. There’s a reason why we don’t allow chat gp answers to help others in this forum.
automation:
trigger:
- platform: state
entity_id: sensor.solarnet_power_grid
to: # null to triggers on any state change but ignores attribute changes
condition:
- condition: template
value_template: "{{ states('input_number.tesla_power_load_helper')|has_value and states('sensor.solarnet_power_photovoltaics')|has_value }}"
action:
- if:
- condition: numeric_state
entity_id: input_number.tesla_power_load_helper
above: sensor.solarnet_power_photovoltaics
then:
- service: number.set_value
target:
entity_id: input_number.tesla_solar_to_grid_helper
data:
value: 0
- if:
- condition: numeric_state
entity_id: input_number.tesla_power_load_helper
below: sensor.solarnet_power_photovoltaics
then:
- service: number.set_value
target:
entity_id: input_number.tesla_solar_to_grid_helper
data:
value: "{{ states('sensor.solarnet_power_photovoltaics')|float(0) - states('input_number.tesla_power_load_helper')|float(0) }}"
Note that you have not specified an action for when input_number.tesla_power_load_helper equals sensor.solarnet_power_photovoltaics. In this case with the above config, nothing happens.
thanks for your help and advice, it doesn’t seem to be working tho.
sensor.solarnet_power_photovoltaics is currently at 0W as its night
input_number.tesla_power_load_helper is currently at 1,334W