PiotrMachowski / Home-Assistant-Lovelace-Local-Conditional-card

This card can show and hide a specific card on current device while not affecting other windows. It does not require any integration to run.
MIT License
61 stars 6 forks source link

Error: expected str instance, Optional found #8

Closed alexanderphoenix closed 1 year ago

alexanderphoenix commented 3 years ago

Hi @PiotrMachowski

After installing this extension I've been getting the following error:

Failed to call service light/turn_on. sequence item 0: expected str instance, Optional found

I didn't realise at first it could've been the local-conditional-card and posted this problem on the home assistant community forum: https://community.home-assistant.io/t/error-expected-str-instance-optional-found/305019

Would you be able to have a look please? I'm curious to have your thoughts on this.

Cheers

PiotrMachowski commented 3 years ago

Hi @alexanderphoenix!

I think that it can be caused by this card, for now it should work with this change in your config:

type: button
tap_action:
  action: call-service
  service: light.turn_on
  service_data:
    entity_id: light.master_bedroom_lamp
    brightness_pct: 10
show_name: false
icon: 'mdi:lightbulb-outline'

Can you confirm if this solves your problem?

alexanderphoenix commented 3 years ago

Nice one @PiotrMachowski, that worked, thank you!

So the target line was misleading? The weird thing is that I made that configuration using the GUI, surely that shouldn't have happened?

Do you think this is a bug with the frontend perhaps? Is that something worth raising with home assistant?

alexanderphoenix commented 3 years ago

@PiotrMachowski I have updated the community post with your suggestion, in case someone else experiences this problem in the future.

Could it be the case that the frontend was updated with a new target function that would then need to be caught by the local-condition-card code?

Weirdly, and I cannot explain why, the error only pops up when I navigate to a view that contains your custom card, and not before. I'd have thought the whole interface would get loaded at once, maybe this indicates some other abnormality?

PiotrMachowski commented 3 years ago

UI is loaded dynamically - only visible stuff is loaded. The problem is caused by this card, because it "injects" itself inside of calling service process to intercept appropriate service calls and forward other ones. This card has been developed before target was added to HA, so it doesn't forward it, which creates your problem

alexanderphoenix commented 3 years ago

That answers the question perfectly, thank you for the explanation!

PiotrMachowski commented 1 year ago

Fixed in v2.0.0