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

using templates in start_watering service call #49

Open
precbioinf opened this issue Dec 30, 2020 · 2 comments
Open

using templates in start_watering service call #49

precbioinf opened this issue Dec 30, 2020 · 2 comments

Comments

@precbioinf
Copy link

Describe the bug
I am attempting to call bhyve.start_watering with minutes specified by a template:

- type: button
  tap_action:
    action: call-service
    service: bhyve.start_watering
    service_data:
      entity_id: switch.backyard_zone
      minutes: '{{ states("input_number.watering_time") | int }}'

But it reports "expected int for dictionary value @ data['minutes']"

The "input_number.watering_time" is correctly set.
In Developer Tools, template editor, the same {{...}} reports the correct value.

timer is {{ states("input_number.watering_time") | int }}
shows:
timer is 6

Logs

Logger: homeassistant.components.websocket_api.http.connection
Source: core.py:1399
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 3:54:30 PM (2 occurrences)
Last logged: 3:54:41 PM

[2928512784] expected int for dictionary value @ data['minutes']

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 135, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1399, in async_call
    processed_data = handler.schema(service_data)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 594, in validate_dict
    return base_validate(path, iteritems(data), out)
  File "/usr/local/lib/python3.8/site-packages/voluptuous/schema_builder.py", line 432, in validate_mapping
    raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: required key not provided @ data['minutes']

I tried data_template instead of service_data, then it reports
required key not provided @ data['entity_id']

@sebr
Copy link
Owner

sebr commented Jan 1, 2021

Good question... I can reproduce the same issue. I'll dig around, for now I think a viable workaround might be to use a script?

@briodan
Copy link

briodan commented Jul 6, 2021

not sure if it helps or not but I'm using a virtual switch and an automation to go around this. Automation listens for the virtual switch to turn on, then runs the watering cycle based on the time template and then resets the virtual switch to off.

trigger:
  - platform: state
    entity_id: input_boolean.virtual_switch
    to: 'on'
condition: []
action:
  - service: bhyve.start_watering
    data:
      entity_id: switch.zone
      minutes: '{{ states(''input_number.bhyve_run_time'') | int }}'
  - wait_template: '00:01:00'
  - service: input_boolean.turn_off
    target:
      entity_id: input_boolean.virtual_switch
mode: single

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants