Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State-dependent actions #850

Open
hilburn opened this issue May 24, 2024 · 8 comments
Open

State-dependent actions #850

hilburn opened this issue May 24, 2024 · 8 comments
Labels
FR Feature Request

Comments

@hilburn
Copy link

hilburn commented May 24, 2024

I have a button which I would like to call different services on tap_action depending on state.

Ideally the current action format could be implemented in the state list, along with color, icon, styles etc

Current;y I have implemented the following with templates for which service/targets to use:

tap_action:
  action: call-service
  service: >-
    [[[ if (variables.boost_on) return "schedule_state.clear_overrides"; else
    return "input_button.press" ]]]
  data: {}
  target:
    entity_id: >-
      [[[ if (variables.boost_on) return "sensor.heating_schedule"; else return
      "input_button.heating_boost" ]]]

Which works ok for the moment, but could see getting rather unwieldy with more than 2 states, or more difficult if e.g. wanting to target a label rather than an entity in one of the states

@hilburn hilburn added the FR Feature Request label May 24, 2024
@beringtom
Copy link

2nd this! Using a toggle action on blinds with tilt needs a script or automation to trigger it,

@lduesing
Copy link

lduesing commented Dec 26, 2024

That's why
tap_action: | [[[ if (states['binary_sensor.dishwasher.status_doorstate'].state === 'on') { return 'action: none'; } else { return 'action: toggle'; } ]]]
doesn't work?
even if documentation tells:
`Those are the configuration fields which support templating:
[...]

  • Everything field in *_action

[...]
`

@Mariusthvdb
Copy link
Contributor

Mariusthvdb commented Dec 26, 2024

but it has been working since forever:

   action: >
     [[[ return variables.z_wave ? 'call-service' : 'call-service'; ]]]
   service: >
     [[[ return variables.z_wave ? 'zwave_js.refresh_value' : 'script.turn_on'; ]]]
   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; ]]]

or conditional path:

  hold_action:
    action: navigate
    navigation_path: >
      [[[ return window.location.pathname.split('/')[2] === 'familie_overzicht'
        ? '/ui-familie/onderweg' : '/ui-familie/familie_overzicht'; ]]]

other example:

tap_action:
  action: call-service
  service: >
    [[[ return entity.state === 'active' ? 'timer.pause' : 'timer.start'; ]]]
  data:
    entity_id: timer.tester
hold_action:
  action: call-service
  service: >
    [[[ return entity.state === 'active' ? 'timer.cancel' : 'timer.pause'; ]]]
  data:
    entity_id: timer.tester

for more support, hop over to the community, and please close this FR ;-)

@hilburn
Copy link
Author

hilburn commented Dec 28, 2024

@Mariusthvdb - no I won't close the FR as I specifically mention that the js template solution does work, it's just ugly and unintuitive compared to bringing it into the state structure used for conditional everything else

@Mariusthvdb
Copy link
Contributor

Mariusthvdb commented Dec 28, 2024

ok I see, missed that bit...

well in that case, don't hold your breath, as this card is on a strictly 'keep alive if possible' status, and no new features will be added.

you need to change your title though, because what you have there now is available via templates

@hilburn
Copy link
Author

hilburn commented Dec 28, 2024

The title is fine. Just read more than the title before commenting

@Mariusthvdb
Copy link
Contributor

Mariusthvdb commented Dec 28, 2024

you're making trouble here.

the title 'State-dependent actions' is not fine at all, it says exactly nothing. Is this an issue, is this a FR. nothing.

You could help your self, and more importantly the community that gets notified of these new issues (because that is what this is in the repo) not waste their time by describing what the issue is.

@hilburn
Copy link
Author

hilburn commented Dec 28, 2024

It has a FR label and has had it for the last... 7 months.
Nothing in the "Submit a FR" form suggests anything else is needed.
You've also just told me the entire project is in "limp along" mode, uninterested in actually adding any new features - making this whole thread a waste of time regardless of the title.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FR Feature Request
Projects
None yet
Development

No branches or pull requests

4 participants