button-card icon indicating copy to clipboard operation
button-card copied to clipboard

No conditional properties?

Open whodat opened this issue 1 year ago • 2 comments

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 avatar Jul 07 '23 01:07 whodat

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

image

whodat avatar Jul 07 '23 19:07 whodat

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; ]]]

Mariusthvdb avatar Jul 10 '23 12:07 Mariusthvdb