Automation creation

Hello everyone,
here I am again asking for help.
I have a Shelly 3em that measures both the production of the photovoltaic system and the consumption from the electricity grid. Then I connected a Shelly 1 to an air conditioner.
He would like to make this happen: when the production measured by the Shelly 3em drops below 1.2 Kwh it gives the input to the Shelly 1 connected to the air conditioner to cut off the current.
But I don’t know where to start.

Pretty sure you mean 1.2kW not kWh.
Use a numeric state trigger.

trigger:
  platform: numeric_state
  entity_id: sensor.your_production_sensor
  below: 1.2

This is your action. Turn off the Shelly switch.

action:
  service: switch.turn_off
  target:
    entity_id: switch.your_ac_shelly_switch
1 Like

Hello I tried to create the automation, but when I go to check the configuration it gives me this error in the picture
Immagine 2022-08-09 204108

It looks like you tried to create the automation in the configuration.yaml file instead of automations.yaml.

Maybe you should try the automation editor UI instead.

yes you are right I have the wrong file, now I have entered automation in automation.yaml but it does not work anyway. I also tried to create automation from UI but it doesn’t work anyway … I don’t understand where I’m wrong.
This is my current automation:
trigger:
platform: numeric_state
entity_id: sensor.produzione_energy_returned
below: 1.2
action:
service: switch.turn_on
target: switch.luci_scala_centrale

maybe I skip a few steps?

Please format your configuration correctly for the forum: https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16

Also keep in mind that the energy has to cross from above 1.2 to below 1.2 to trigger. If it was already below 1.2 when you created the automation it wont trigger.

Also also you need to perform a config check and reload automations if using YAML.

ah ok, so first it must be above 1.2 and then go down, because I used a lower value as a test to see if it worked, maybe that’s the problem too

Works !!! The unit of measurement was wrong and had to be expressed watts so not 1.2 but 1200 :upside_down_face: