Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

constrain_person not working #1437

Closed
aneisch opened this issue Dec 31, 2021 · 3 comments
Closed

constrain_person not working #1437

aneisch opened this issue Dec 31, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@aneisch
Copy link
Contributor

aneisch commented Dec 31, 2021

I'm trying to constrain my callbacks based on person presence but it is not working. I don't think I'm doing anything wrong because both constrain_presence and constrain_input_boolean are working as expected.

My app config:

Indoor Light Automation Sunset:
  module: entity_timer
  class: Timer
  constrain_person: anyone
  time_on: sunset - 00:20:00
  entities: light.andrew_desk_lamp
  brightness: 255

My app:

import appdaemon.plugins.hass.hassapi as hass

class Timer(hass.Hass):
  def initialize(self):
    # DEBUG: Log whether my constraints should be applied
    if self.noone_home(person=True):
      self.log("No one home")
    if self.anyone_home(person=True):
      self.log("Anyone home")
    if self.everyone_home(person=True):
      self.log("Everyone home")

    if "time_on" in self.args:
      time_on = self.parse_time(self.args["time_on"])
      self.run_daily(self.on, time_on)

    if "time_off" in self.args:
      time_off = self.parse_time(self.args["time_off"])
      self.run_daily(self.off, time_off)

  def on(self, kwargs):
    for device in self.split_device_list(self.args["entities"]):
        self.log("Turning on " + device)
        if "brightness" in self.args and "light." in device: # API failure if we pass brightness when non-light
          self.turn_on(device, brightness = self.args["brightness"])
        else:
          self.turn_on(device)

  def off(self, kwargs):
    for device in self.split_device_list(self.args["entities"]):
        self.log("Turning off " + device)
        self.turn_off(device)

Logs:

2021-12-31 15:57:27.972737 INFO AppDaemon: App 'Indoor Light Automation Sunset' added
2021-12-31 17:16:11.000000 INFO AppDaemon: Initializing app Indoor Light Automation Sunset using class Timer from module entity_timer
2021-12-31 17:16:14.223652 INFO Indoor Light Automation Sunset: No one home
2021-12-31 17:16:23.000000 INFO Indoor Light Automation Sunset: Turning on light.andrew_desk_lamp
@Odianosen25
Copy link
Collaborator

Hello @aneisch,

I believe the constrain_person, is only to be used with the person entity.

You sure its all setup correctly?

Regards

@aneisch
Copy link
Contributor Author

aneisch commented Jan 3, 2022

https://appdaemon.readthedocs.io/en/latest/APPGUIDE.html?highlight=constrain_person#person suggests that the configuration options are the same as constrain_presence

@acockburn acockburn added the bug Something isn't working label Mar 3, 2023
@acockburn
Copy link
Member

Fixed in 4.0.3

acockburn added a commit that referenced this issue Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants