klogg
(Klogg)
September 1, 2020, 8:21am
1
It’s only a small irritation but why can’t input_*
services be writtten
For example:
- service: input_text.set_value
entity_id: input_text.my_input_text
value: Some text here
Instead of
- service: input_text.set_value
entity_id: input_text.my_input_text
data:
value: Some text here
Obviously using data_template
where necessary
- service: input_text.set_value
data_template:
entity_id: input_text.my_input_text
value: "{{ some template here }}"
petro
(Petro)
September 1, 2020, 11:50am
2
All extra attributes go inside data, even entity_id. entity_id is also the only exception to the rule (it can go inside or outside). If this change were to go through, this would be the only service that doesn’t use data/data_template.
Why does it require data? Because under the hood, the call.service function requires the domain, the service string, and a dictionary containing information for the service. The domain and service string are pulled from the service by splitting on the .
. The dictionary containing information is data
. Nothing needs to be modified, it’s a straight shot into the call.
If we were to change this, all service calls would need to be tailored for this change as well. It could be done, but is the juice worth the squeeze? Not really. It’d be a massive amount of busy work changing all the validation in every integration. Then after all that’s done, you’d have to change actions inside the script editor & automation editor because the data is served up differently. Then lovelace’s tap action call-service would need to be changed to allow values outside service_data… I’m sure there’s other things too that aren’t coming to the top of my head.
tom_l
September 1, 2020, 12:25pm
3
In some instances placement of entity id is actually really specific and inconsistent:
opened 11:54AM - 08 Nov 19 UTC
closed 12:49PM - 28 Jan 21 UTC
<!-- READ THIS FIRST:
- If you need additional help with this template please r… efer to https://www.home-assistant.io/help/reporting_issues/
- Make sure you are running the latest version of Home Assistant before reporting an issue: https://github.com/home-assistant/home-assistant/releases
- Frontend issues should be submitted to the home-assistant-polymer repository: https://github.com/home-assistant/home-assistant-polymer/issues
- iOS issues should be submitted to the home-assistant-iOS repository: https://github.com/home-assistant/home-assistant-iOS/issues
- Do not report issues for integrations if you are using a custom integration: files in <config-dir>/custom_components
- This is for bugs only. Feature and enhancement requests should go in our community forum: https://community.home-assistant.io/c/feature-requests
- Provide as many details as possible. Paste logs, configuration sample and code into the backticks. Do not delete any text from this template!
-->
**Home Assistant release with the issue:** 0.101.1
**Last working Home Assistant release (if known):** unknown
**Operating environment (Hass.io/Docker/Windows/etc.):**
venv on raspbian buster
**Integration:**
Automation, lights, manual_control_panel, others?
**Description of problem:**
Automation actions have an `entity_id` key. For some types of actions, adding a `data` block requires the `entity_id` key to move inside `data`. Others do not require this. This leads to confusion on what we are supposed to do during configuration. There seem to be conflicting requirements across integrations.
This could be a documentation issue, but the conflicting requirements even within a single component like light, I would argue, suggests enforcing a universal behavior.
**Problem-relevant `configuration.yaml` entries and (fill out even if it seems unimportant):**
This one was reported to not work for someone usig a zwave light, but moving it inside data works
```yaml
action:
- service: light.turn_on
entity_id: light.led_salon
data:
brightness: 50
```
But, this one is reported to work using presumably the lifx integration.
```yaml
action:
- service: light.turn_off
entity_id: light.lifx_bottom_of_stairs
data:
transition: 1
```
This one doesn't work for manual alarm control panel, but again moving it inside `data` works.
```yaml
action:
- service: alarm_control_panel.alarm_disarm
entity_id: alarm_control_panel.house_alarm
data:
code: !secret alarm_code
```
This one works for a custom component alarm:
```yaml
action:
- service: alarm_control_panel.alarm_disarm
entity_id: alarm_control_panel.house
data:
code: !secret alarm_code
```
**Traceback (if applicable):**
There are a lot of debug messages from an automation firing with my alarm code in them in plain text, I can scrub them if this is thought to be extra useful
**Additional information:**. These examples were taken from https://community.home-assistant.io/t/disarming-a-manual-alarm-control-panel-in-automation-with-a-code/146605
petro
(Petro)
September 1, 2020, 1:17pm
4
Yep, that’s why you’ll notice most of my support posts always have this format (because it works 100% of the time):
service: x.y
data:
entity_id: a.b
tom_l
September 1, 2020, 1:30pm
5
Except for this one instance:
Try it like this:
action:
- data:
volume_level: 0.2
entity_id: media_player.bose_soundtouch
service: media_player.volume_set
- service: tts.google_translate_say
entity_id: media_player.bose_soundtouch
data_template:
message: "The weather for today is {{ states('weather.test_home') }}"