danobot / entity-controller

Home Assistant Entity and lighting controller for managing devices with timers, scripts, and sun-based time restrictions.
https://danobot.github.io/ec-docs/
GNU General Public License v3.0
294 stars 40 forks source link

Add param support on helper functions #248

Closed maxlyth closed 2 years ago

maxlyth commented 3 years ago

Add param support to helper functions

It seems illogical that param support is specifically unavailable when calling helper functions. This makes it impossible to use a generic script that handles motion where multiple EntityControllers can pass a differentiating parameter to that script. An example might be to pass the room name to the helper function and to the script which could in turn initiate a scene using the same parameter.

Code changes

Modification is restricted to handleTriggerOnDeactivateEntities and handleTriggerOnActivateEntities functions. These functions should be consistent in param handling and effectively the same changes are applied to both

Configuration

  trigger_on_activate: script.room_lights_motion
  trigger_on_deactivate: script.room_lights_off
  service_data:
    variables:
      room: "bedroom"
  service_data_off:
    variables:
      room: "bedroom"

Checklist

Related Issues

Param support in Helper Functions #249

Closes

danobot commented 3 years ago

Merge in the latest from develop branch. Happy to take a look. You're right it is illogical which makes me think there must be a reason I specifically didnt pass parameters along.

maxlyth commented 2 years ago

This seems to have stagnated so I have added a concrete example to the documentation in Doc Pull request #4 https://github.com/danobot/ec-docs/pull/4

danobot commented 2 years ago

Thank you for your contribution