Clooos / Bubble-Card

Bubble Card is a minimalist card collection for Home Assistant with a nice pop-up touch.
MIT License
1.62k stars 46 forks source link

unable to pass arguments to a script from within a pop-up card. #277

Open thingray opened 7 months ago

thingray commented 7 months ago

I use pop-up card triggered by a binary sensor state. The cards pop up as expected. Wanted to use the double tap action to call a service to reset the sensor state ( sort of an acknowledge). When used in the pop-up card itself , no arguments are passed to the script. ( the script checks for missing argument). When I use the same syntax on a button card or image-entity card, it works as expected.

HA 2023.10.5 running in a container on a NAS. Bubble card V 1.5.3

The script I use comes from https://community.home-assistant.io/t/how-to-manually-set-state-value-of-sensor/43975/8f From rodpayne :

==================================================================================================

python_scripts/set_state.py

==================================================================================================

--------------------------------------------------------------------------------------------------

Set the state or other attributes for the entity specified in the Automation Action

--------------------------------------------------------------------------------------------------

inputEntity = data.get('entity_id') if inputEntity is None: logger.warning("===== entity_id is required if you want to set something.") else:
inputStateObject = hass.states.get(inputEntity) inputState = inputStateObject.state inputAttributesObject = inputStateObject.attributes.copy()

for item in data:
    newAttribute = data.get(item)
    logger.debug("===== item = {0}; value = {1}".format(item,newAttribute))
    if item == 'entity_id':
        continue            # already handled
    elif item == 'state':
        inputState = newAttribute
    else:
        inputAttributesObject[item] = newAttribute

hass.states.set(inputEntity, inputState, inputAttributesObject)

here is the code that works: cards:

But when I try to use that specific section with tap_action our double tap action in the pop-card tap_action: action: call-service service: python_script.set_state data: entity_id: binary_sensor.notif_poele state: 'off' The script returns : 2024-01-04 19:41:16.686 WARNING (SyncWorker_16) [homeassistant.components.python_script.set_state.py] ===== entity_id is required if you want to set something.

Which points to the argument is not passed. Tried various combination of quotes, double quotes, nothing helps. The work around is obviously to use another card under the pop-up. So no big issue, I just dunno if it is an intended behavior or an issue. But it had me banging my head for awhile. :)

Clooos commented 7 months ago

Hi, I guess that this issue in on my side. I will take a look!

Edit: One more question, have you tried it as a tap_action in an other custom card? Just to be sure that this is not just an HA error related to the tap actions.

thingray commented 7 months ago

Hi, using a button card in a pop-card, tap action works as stated in ' here is the code that works'. So it seems related specifically to tap actions in the pop-up card itself, if that makes sense.

Clooos commented 2 days ago

Hi, is this possible by any chance that this issue is now fixed? I haven't tried but a lot of the code has changed since.