#Any idea why nothing seemingly happen when callign this script?

28 messages · Page 1 of 1 (latest)

visual cairn
#
entrance_toggle:
  alias: "Toggle Entrance Scene"
  sequence:
    - condition: state
      entity_id: light.entrance
      state: off
    - service: scene.turn_on
      target:
        entity_id: scene.entrance_max
  default:
      - service: scene.turn_on
        target:
          entity_id: scene.entrance_off

I manually check that the condition state is correct, but nothing seeminglt happens. What would be the best way to debug this?

#

what I am trying to do is pretty simple:

if lights are on, call entrance_max, else entrance_off

shell crow
#

I would just use an if/then/else rather than that construct

#

I don't recall what default: even does there

visual cairn
#

still having issues

- entity: light.entrance
  name: Entrance
  tap_action:
    action: call-service
    service: script.entrance_toggle

and

entrance_toggle:
  alias: "Toggle Entrance Scene"
  sequence:
    - if:
        - condition: state
          entity_id: light.entrance
          state: 'off'
      then:
        - service: scene.turn_on
          target:
            entity_id: scene.entrance_max
      else:
        - service: scene.turn_on
          target:
            entity_id: scene.entrance_off
shell crow
#

You should test those service calls in devtools -> Actions

visual cairn
#

ok, so, the script works if I call it from the Services tab!

#

oh right 🤦

#
tap_action:
  action: call-service
  service: script.turn_on
  service_data:
    entity_id: script.entrance_toggle
shell crow
#

I would have expected the first to work as well. It's just an alternate way to call it with some different behavior

visual cairn
#

So, I tried to make this more dynamic, and struggling again.
The image of Call Service you see from the HASS UI works correctly

but if I press the card button we defined before, it doesn't seem to work

- entity: light.entrance
  name: Entrance
  tap_action:
    action: call-service
    service: script.turn_on
    service_data:
      entity_id: script.room_toggle
      variables:
       room: "entrance"
       scene_on: "max"
room_toggle:
  alias: "Toggle Room Scene"
  sequence:
    - if:
        - condition: template
          value_template: "{{ is_state('light.'+room,'off') }}"
      then:
        - service: scene.turn_on
          target:
            entity_id: "{{ 'scene.'+room+'_'+scene_on }}"
      else:
        - service: scene.turn_on
          target:
            entity_id: "{{ 'scene.'+room+'_off' }}"
shell crow
#

You're calling it differently

#

You're switching back and forth

visual cairn
#

mmm, I am not sure I understand

shell crow
#

the way you're calling the script in the image is not the way you're calling it from the button. It's the same difference you noted earlier

#

they're different - just compare the two

visual cairn
#

oooh I see what you mean

#

Mmm i've tried this, but still no luck, I don't really understand :S

- entity: light.entrance
  name: Entrance
  tap_action:
    action: call-service
    service: script.room_toggle
    service_data:
      room: "entrance"
      scene_on: "max"
#

(I am doing Quick Restart every time I make changes)

shell crow
#

it's working fine for me

#
room_toggle:
  alias: "Toggle Room Scene"
  sequence:
    - service: persistent_notification.create
      data:
        message: "{{ 'Room: ' ~ room ~ ', scene_on:' ~ scene_on }}"
#
show_name: true
show_icon: true
type: button
tap_action:
  action: call-service
  service: script.room_toggle
  service_data:
    room: room_test
    scene_on: scene_test
entity: script.room_toggle
name: test

#

Keep looking, I guess

#

I do note that you don't have type: button, so you're not actually defining a button card...

visual cairn
#

ok, first of all, thank you very much for spending your time helping me, I was doing something stupid and it feels like I have wasted your time

#

it turns out that my dashboard UI had the code for the button twice (based on some condition), so because of code duplication, I only made the changes on one of the branches