Conversation
zsarnett
commented
Dec 5, 2018
|
UI Editor will need updated after this is merged |
| } | ||
| const [domain, service] = actionConfig.service.split(".", 2); | ||
| const serviceData = { | ||
| entity_id: config.entity, |
There was a problem hiding this comment.
This has caused issues for some services that don't want the entity_id. I can't recall them off the top of my head, but should require that the service_data be explicitly stated instead?
There was a problem hiding this comment.
If it doesnt want it, the service should ignore it... I think that should be a service fix
There was a problem hiding this comment.
Most services don't work that way. Probably by design.
Invalid service data for light.turn_on: extra keys not allowed @ data['unknown_key']. Got 'someting'
Invalid service data for system_log.write: extra keys not allowed @ data['entity_id']. Got 'light.my_lamp'
There was a problem hiding this comment.
Yeah we should stop trying to be smart and adding the entity automatically.
There was a problem hiding this comment.
We can still automatically populate service data for toggle, but not for normal services.
|
Travis threw an error here: Will also need to look at |
| } | ||
|
|
||
| const action = | ||
| actionConfig && actionConfig.action ? actionConfig.action : "more-info"; |
There was a problem hiding this comment.
Not all the types handled by config have an action field. I don't think any elements are likely working right now with this
There was a problem hiding this comment.
Thats why it has the check for action field
There was a problem hiding this comment.
But you can still define an action type for the elements beyond "more-info". That is lost here.
There was a problem hiding this comment.
Perhaps we should just align the elements now as well? icon, image, state-icon and state-label
There was a problem hiding this comment.
Oh you are saying the elements of picture elements
Yea I havent gotten there yet. Next commit. Looking at that now
There was a problem hiding this comment.
It's fine to have multiple handleClick methods to handle different supported actions for different places in the code
| hass: HomeAssistant, | ||
| config: LovelaceElementConfig | LovelaceCardConfig, | ||
| config: | ||
| | LovelaceElementConfig |
|
This doesn't allow for the "simple" configuration scheme |
|
Correct. I though we decided against that. So that it was better configurable via the editor |
|
Rereading the discussion it seems that way... but it was not what I thought I agreed to. It looks much nicer in a text config, and is similar to the entity list, but as you say it'd have to be converted by the editor on first edit... |
|
I did think we would support the short-form too, when possible. However, given that editors are going to rewrite it and that by not defaulting service-data, I expect that within reasonable time, 95% of our users won't need to write YAML, especially since custom cards can also add config UI. |
src/data/lovelace.ts
Outdated
| [key: string]: any; | ||
| } | ||
|
|
||
| export interface ActionConfig { |
There was a problem hiding this comment.
This is the wrong approach. We should have a separate interface for each action and then have ActionConfig be a union interface: ActionConfig = CallServiceActionConfig & MoreInfoActionConfig
| import { HomeAssistant } from "../../../types"; | ||
| import { ActionConfig } from "../../../data/lovelace"; | ||
|
|
||
| export interface LovelaceElementConfig { |
There was a problem hiding this comment.
In a future PR we need to get rid of this catch all element config. We need to define a type per element, then have 1 type that joins them
|
fixes #2180 |