custom-cards / button-card

❇️ Lovelace button-card for home assistant
MIT License
1.98k stars 244 forks source link

No conditional properties? #713

Open whodat opened 1 year ago

whodat commented 1 year ago

Is it not possible to pass sub-properties conditionally?

If calling opensprinkler.stop, it should not pass "run_seconds" property at all (only opensprinkler.run needs it). I tried just passing null to the property and get this error.

image

(for some reason when I paste this as code within a code block, it removes line formatting) image

whodat commented 1 year ago

Had this idea, but using config template here does not seem to work either...

image

Mariusthvdb commented 1 year ago

you can condition all options inside the hold/tap_action:

tap_action:
   action: >
     [[[ return variables.z_wave ? 'call-service' : 'call-service'; ]]]
   service: >
     [[[ return variables.z_wave ? 'zwave_js.refresh_value' : 'script.turn_on'; ]]]
   service_data:
     entity_id: >
       [[[ return variables.z_wave ? 'sensor.' + variables.id + '_actueel' : 'script.' + variables.id + '_meterget_power'; ]]]
     refresh_all_values: >
       [[[ return variables.z_wave ? true : null; ]]]