garo_wallbox icon indicating copy to clipboard operation
garo_wallbox copied to clipboard

request: Add possibility to set/delete schedule

Open andersdarljung opened this issue 1 year ago • 1 comments

I just started testing this because iffy wifi connection so sometimes my car was not charged in the morning when using on and off commands, but this would be great to have this in the intrgration.

Get currect schedules, curl http://garo:8080/servlet/rest/chargebox/schema

Set a schedule curl -H "Content-Type: application/json" -d '{"schemaId": 10,"start": "22:00:00","stop": "07:00:00","weekday": "3","chargeLimit": 0}' http://garo:8080/servlet/rest/chargebox/schema

Delete a schedule curl -X DELETE http://garo:8080/servlet/rest/chargebox/schema/1

andersdarljung avatar Apr 23 '24 12:04 andersdarljung

+1, would be a great addition!

arrelid avatar Jul 13 '24 13:07 arrelid

Any ideas on how HA should handle this... there isn't really a base entity I can use to describe a schema entry.

sockless-coding avatar Sep 17 '24 08:09 sockless-coding

I think a start time and how long we want the schedule to be active.

so to helpers and then the integrations sets the schedule.

I have these rest commands.

rest_command:
  set_garo_schema:
    url: http://IP:8080/servlet/rest/chargebox/schema
    method: POST
    headers:
      accept: "application/json, text/html"
      user-agent: 'Mozilla/5.0 {{ useragent }}'
    payload: '{"schemaId": 1,"start": "{{ start }}","stop": "{{ stop }}:00:00","weekday": "{{ day }}","chargeLimit": 0}'    content_type:  'application/json; charset=utf-8'
    verify_ssl: true

  delete_garo_schema:
    url: http://IP:8080/servlet/rest/chargebox/schema/1
    method: DELETE
    headers:
      accept: "application/json, text/html"
      user-agent: 'Mozilla/5.0 {{ useragent }}'
    content_type:  'application/json; charset=utf-8'

called by these actions in an automations.

data:
  start: "{{ states('input_datetime.starta_laddbox') }}"
  stop: >-
    {% if (as_timestamp(today_at(states('input_datetime.starta_laddbox')) +
    timedelta(hours=4))| timestamp_custom ('%H') | int) < 15 and
    (as_timestamp(today_at(states('input_datetime.starta_laddbox')))|
    timestamp_custom ('%H') | int) > 15  %} 00 {% else %}
    {{as_timestamp(today_at(states('input_datetime.starta_laddbox')) +
    timedelta(hours=4))| timestamp_custom ('%H') | int}} {% endif %}
  day: >-
    {% if (as_timestamp(today_at(states('input_datetime.starta_laddbox')))|
    timestamp_custom ('%H') | int) < 15 %} 
      {% if (now().weekday()+2) != 8 %}
        {{now().weekday()+2}} 
      {% elif (now().weekday()+2) == 8 %}
        1 
      {% endif %}
    {% else%} {{now().weekday()+1}} {% endif %}
action: rest_command.set_garo_schema
condition: template
value_template: >-
  {{ (as_timestamp(today_at(states('input_datetime.starta_laddbox')) +
  timedelta(hours=4))| timestamp_custom ('%H') | int) < 15 and
  (as_timestamp(today_at(states('input_datetime.starta_laddbox')))|
  timestamp_custom ('%H') | int) > 15 and
  (as_timestamp(today_at(states('input_datetime.starta_laddbox')) +
  timedelta(hours=4))| timestamp_custom ('%H') | int) != 00}}

data:
  start: "00:00:00"
  stop: >-
    {{as_timestamp(today_at(states('input_datetime.starta_laddbox')) +
    timedelta(hours=4))| timestamp_custom ('%H')}}
  day: >-
    {% if (as_timestamp(today_at(states('input_datetime.starta_laddbox')) +
    timedelta(hours=4))| timestamp_custom ('%H') | int) < 15 %}
          {% if (now().weekday()+2) != 8 %}
        {{now().weekday()+2}} 
      {% elif (now().weekday()+2) == 8 %}
        1 
      {% endif %} {% else %} {{now().weekday()+1}} {% endif %}
action: rest_command.set_garo_schema

These are triggerd by a input_datetime that is set by another automation.

I have no real idea how or if this helps but this is what i have that sortof works.

andersdarljung avatar Sep 17 '24 08:09 andersdarljung

I guess I could add some dynamic sensors with additional attributes for each schedule entry and some custom services to control them

sockless-coding avatar Sep 17 '24 08:09 sockless-coding

I've added a new sensor: image

And some new service calls:

add_schedule:
  description: Add a new schedule for the EVSE.
  fields:
    entity_id:
      description: Name(s) of entities to change.
      example: "sensor.garage_schedule"
    start:
      description: Start time in (e.g., '08:00').
      example: "08:00"
    stop:
      description: Stop time in (e.g., '17:00').
      example: "17:00"
    day_of_the_week:
      description: Day of the week ('MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY', 'SUNDAY']).
      example: "Monday"
    charge_limit:
      description: Charge limit for this schedule in Amperes (A).
      example: 16

set_schedule:
  description: Update schedule for the EVSE.
  fields:
    entity_id:
      description: Name(s) of entities to change.
      example: "sensor.garage_schedule"
    id:
      description: ID of the schedule to update.
      example: 1
    start:
      description: Start time in (e.g., '08:00').
      example: "08:00"
    stop:
      description: Stop time in (e.g., '17:00').
      example: "17:00"
    day_of_the_week:
      description: Day of the week ('MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY', 'SUNDAY']).
      example: "Monday"
    charge_limit:
      description: Charge limit for this schedule in Amperes (A).
      example: 16

remove_schedule:
  description: Remove a specific schedule from the EVSE.
  fields:
    entity_id:
      description: Name(s) of entities to change.
      example: "sensor.garage_schedule"
    id:
      description: ID of the schedule to remove.
      example: 1

sockless-coding avatar Sep 17 '24 20:09 sockless-coding