zacs / ha-nfl

NFL game scores custom component for Home Assistant
43 stars 32 forks source link

Support for an event handler? #21

Closed dredwater closed 2 years ago

dredwater commented 2 years ago

Added feature request to fire an event when home or opponent team score. The NHL integration (https://github.com/JayBlackedOut/hass-nhlapi) has it and it makes it really easy to setup an automation when score change. Thanks!

vasqued2 commented 2 years ago

You can already trigger an automation w/ a score change.

Here is mine for a touchdown, but you could do it for any score change if you wanted to...

alias: Automation - OSU Touchdown
description: ""
trigger:
  - platform: state
    entity_id: sensor.football_buckeyes
    attribute: team_score
condition:
  - condition: template
    value_template: >-
      {{ trigger.to_state.attributes.team_score | int >
      (trigger.from_state.attributes.team_score | int + 5) }}
action:
      your-action-here
dredwater commented 2 years ago

This is awesome. Suggest to add this code snippet or info into the Readme. Thanks!