mampfes / ha_epex_spot_sensor

Provides helper sensors for EPEX Spot integration.
MIT License
65 stars 5 forks source link

How to use EPEX SPOT SENSOR in an automation? #7

Closed WimDeceuninck closed 9 months ago

WimDeceuninck commented 9 months ago

Hi Steffen,

I was able to install EPEX SPOT SENSOR successfully, and the sensor works fine.

But I struggle when using the sensor in a simple automation with a call service switch toggle on/off for a relay. The relay turns on/off when the sensor 'Enabled' -attribute changes from 'false' to 'true', instead of following the sensor 'Data' -attributes start and end times.

I don't see what I'm doing wrong. Would you please help me with this?

Below is the information about the sensor and the automations I made.

Thanks in advance for your help.

Kind regards, Wim

image

image

image

mampfes commented 9 months ago

You have to use the state of the sensor, not attribute.

Example (not tested!):

description: ""
mode: single
trigger:
  - platform: state
    entity_id:
      - binary_sensor.my_epex_spot_sensor
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: binary_sensor.my_epex_spot_sensor
            state: "on"
        sequence:
          - service: switch.turn_on
            target:
              entity_id: switch.my_switch
            data: {}
      - conditions:
          - condition: state
            entity_id: binary_sensor.my_epex_spot_sensor
            state: "off"
        sequence:
          - service: switch.turn_off
            target:
              entity_id: switch.my_switch
            data: {}
WimDeceuninck commented 9 months ago

Hello Steffen,

Thank you very much for your quick answer.

As you can see, I am an absolute beginner with HA and I still have a lot to learn... :-)

I added a new automation based on your YAML code. Normally this automation should work perfectly. I will confirm you tomorrow.

Kind regards, Wim

alias: Relay 27 Switch toggle on/off (EPEX SPOT BINARY SENSOR 9PM - 6AM - CONTIGUOUS) description: "" trigger:

WimDeceuninck commented 9 months ago

Thanks for your help Steffen! The automation works perfectly. Kind regards, Wim