Help to start working with scripts

Hi,

I have now got the basics of understanding HA but scripts has confused the hell out of me!

I wish to create a script to get my current heating schedule and save it to a file.

I can call the service from the developer tools which works fine;

Service
wiser.get_schedule

Entity
climate.wiser_lounge

Service Data

entity_id: climate.wiser_lounge
filename: /config/schedules/lounge.yaml

I wish to write a script to call the wiser.get_schedule service and save multiple files for the different rooms, basically it uses the same service but the entity id changes to each room name.

Any help appreciated

I searched Integrations for “wiser” but found nothing. Is it a custom component?

Yes

The service wiser.get_schedule works from the developer tools but I’m stuck how to implement this as a script instead of running it from the developers menu

I’ve solved it.

How? Others might also be stuck on something like this and find your question in their search results. Just reading this thread and seeing it end with “I fixed it” may be frustrating for them - but if you posted the details of “how” you fixed it, you’ll be helping them avoid the troubles you had and they’ll likely be grateful!

1 Like

Point noted…it was more fluke than anything.

I tried to set the script from the dashboard and it entered the script in my config file as;

'1595629881146':
  alias: Test
  sequence:
  - data:
      filename: /config/schedules/living_room.yaml
    entity_id: climate.wiser_living_room
    service: wiser.set_schedule

However if I changed the order to;

1595551088995':
  alias: Test
  sequence:
  - data:
      entity_id: climate.wiser_living_room
      filename: /config/schedules/living_room.yaml
    service: wiser.set_schedule

it works. I don’t understand why creating a new script using the + in the script dashboard formats the file the way it does.

Python is very particular about spacing/indent. It may not be the order but the indenting of the second item after - data:

Yes very strange but that’s how to built in engine compiles the text.