Rainmachine Integration - Add support to change program start time

Hello @bachya,

I’m trying to get the hang of how integrations work in the system and how to extend them. So far not very successfull.
I started toying around with your Rainmachine integration, since I am moving stuff from a different system to HomeAssistant.

I have a specific use-case that I currently cannot do with the rainmachine integration: Modifying program start times (and possibly names).
This is all exposed via the API.

On my older home automation system I had a logic that set the start time for all programms to a “latest possible start time” value.
Then I would monitor several parameters, mainly PV energy production. When the excess energy surpassed a certain level, I would set the start time to “NOW + 5 minutes”. (And also logged the start time by adding it to the program name).

I assume for you that is likely a quick change. Maybe you can have a look at it.

BR

Sebastian

What about an automation that calls the rainmachine.start_program action at the appropriate time? High-level:

  1. Have the automation trigger when your excess energy surpasses the target level.
  2. Add a 5-minute delay.
  3. Run rainmachine.start_program.

Hi @bachya,

the issue with the “start_program” call (regardless of via the integration or directly via the API), is that this will always start the program with the default run time.
The RM unfortunately does not have a way to trigger a program while still considering the calculated ET.
So the only way to work around that is to modify the start time.

In case someone is interested, I now solved it with a rest_command:

  rainmachine_update_program_time:
    url: "https://{{states('input_text.rainmachine_ip')}}:8080/api/4/program/{{program_id}}?access_token={{states('sensor.rainmachine_token')}}"
    method: POST
    payload: '{"name":"{{name}} ({{new_time}})", "startTime":"{{new_time}}"}'
    content_type: "Content-Type:application/json"
    verify_ssl: false

Where rainmachine_token is retreived by a template sensor, to simplify the calls:

sensor:
  - platform: rest
    name: "Rainmachine Token"
    resource_template: "https://{{states('input_text.rainmachine_ip')}}:8080/api/4/auth/login"
    method: POST
    payload: '{"pwd": "PASSWORD", "remember": 1 }'
    value_template: "{{ value_json.access_token }}"
    scan_interval: 300
    verify_ssl: false