chore: simplify off-action error message (#29707)

This commit is contained in:
andig 2026-05-06 16:11:34 +02:00 • committed by GitHub
parent bd651da8ff
commit de8d02282c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View file

@ -247,7 +247,7 @@ func (c *Connection) CallSwitchService(entity string, turnOn bool) error {
case "button", "input_button":
// Buttons are stateless — they only have a press action.
if !turnOn {
return fmt.Errorf("entity %s (domain %s) has no off action", entity, domain)
return fmt.Errorf("entity %s has no off action", entity)
}
service = "press"
default:

View file

@ -35,8 +35,8 @@ func TestCallSwitchService_DomainDispatch(t *testing.T) {
{"switch turn_off", "switch.foo", false, "/api/services/switch/turn_off", ""},
{"button press", "button.tesla_model_x_wake_up", true, "/api/services/button/press", ""},
{"input_button press", "input_button.bar", true, "/api/services/input_button/press", ""},
{"button no off", "button.foo", false, "", "entity button.foo (domain button) has no off action"},
{"input_button no off", "input_button.bar", false, "", "entity input_button.bar (domain input_button) has no off action"},
{"button no off", "button.foo", false, "", "entity button.foo has no off action"},
{"input_button no off", "input_button.bar", false, "", "entity input_button.bar has no off action"},
}
for _, tc := range tests {