bob1de / hass-apps

Some useful apps and snippets to empower Home Assistant and AppDaemon even more.
Apache License 2.0
85 stars 23 forks source link

[Schedy] Using attributes on actor type generic2 throws errors #50

Closed SeaquestNet closed 4 years ago

SeaquestNet commented 4 years ago

Hi!

Im trying to use the new generic2 actor type with the custom attributes to get tuple values. It throws errors though and doesn't seem to fill placeholder.

Error:

2020-03-17 22:30:00.408621 ERROR schedy_lights: !!! [R:Gillestugan] [A:light.gillestugan_lights] Couldn't format service data '{attr2}' with values {'entity_id': 'light.gillestugan_lights', 'attr1': 'on', 'attr2': 64}: KeyError('attr2'), omitting data.
2020-03-17 22:30:00.409955 INFO schedy_lights: <-- [R:Gillestugan] [A:light.gillestugan_lights] Calling service 'light/turn_on', data = {'param2': '{attr2}', 'entity_id': 'light.gillestugan_lights'}.

Configuration:

actor_templates:
  default:
    template: light

  light:
    attributes:
      - attribute: state
      - attribute: brightness
    values:
      - value: ["on", "*"]
        calls:
          - service: light.turn_on
            data:
              brightness: "{attr2}"
            include_entity_id: true
      - value: ["off", "*"]
        calls:
          - service: light.turn_off
      - value: [None]
        calls:
          - service: light.turn_off
    send_retries: 1
    ignore_case: true
bob1de commented 4 years ago

Hi,

Thanks for reprting.

Could you please also provide the log showing the errors it throws?

Best regards Robert

bob1de commented 4 years ago

Ah, sorry, I overlooked the error message, will investigate it.

bob1de commented 4 years ago

Ok, should be fixed in master branch. Could you please confirm by using this URL to install hass-apps instead of hass-apps in your requirements.txt or hassio addon config:

https://github.com/efficiosoft/hass-apps/archive/master.zip
SeaquestNet commented 4 years ago

Hi!

Thanks for the quick fix @efficiosoft!

Tried to test it but can't install master version. Might have something to do with your change here: https://github.com/efficiosoft/hass-apps/commit/dc45882f0af3acf6cb073440805e5d6e83320468

Did you miss a quote (")?

Error from appdaemon:

command: /usr/local/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-v20e0t98/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-v20e0t98/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-req-build-v20e0t98/pip-egg-info
cwd: /tmp/pip-req-build-v20e0t98/
Complete output (6 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-req-build-v20e0t98/setup.py", line 30
"appdaemon >= 3.0, < 5
^
SyntaxError: EOL while scanning string literal
----------------------------------------
bob1de commented 4 years ago

Did you miss a quote (")?

Indeed I did! I'm just wondering why that didn't cause my installation to fail... Should be fixed now.

SeaquestNet commented 4 years ago

Well, you can consider this working! Thank you and keep up the good work!

bob1de commented 4 years ago

Thanks for confirming.

BTW, Instead of

- value: ["off", "*"]

you could just use

- value: ["off"]

That way you only need to return "off" from your schedule instead of a 2-tuple of which the second item has no actual meaning for a light that's turned off.

bob1de commented 4 years ago

Will issue a bugfix release for this today.