Getting there but looks like a problem with the set command as nothing happens when changing the value and it doesn’t log anything either.
I think this might not be working as expected:
rest_command:
openevse_rapi:
method: post
timeout: 30
username: !secret OPENEVSE_USERNAME
password: !secret OPENEVSE_PASSWORD
url: "{{ url | default('http://' ~ host ~ '/r?json=1&rapi=' ~ rapi, true) }}"
Essentially the set above should create a url like so:
http://192.168.0.100/r?rapi=%24SC+10
as when I run this in my browser it actually applies the changes. The 10 is the value I can pass in from that number template just created.
petro
(Petro)
November 8, 2021, 2:08pm
22
I just looked at your script and you had errors, updated the post
petro:
template:
- number:
- unique_id: openevse_pilot
name: Pilot
step: 1
state: "{{ states('sensor.openevse_pilot') }}"
availability: "{{ states('sensor.openevse_pilot') not in ['unavailable','unknown'] }}"
min: >
{%- set ret = state_attr('sensor.openevse_rapi_gc', 'ret') -%}
{%- set rgx = '(?<=^\$OK) +([0-9]+) +([0-9]+)' -%}
{%- set v = ret | regex_findall_index(rgx) -%}
{{- [10, [6, v[0]|int]|max] | min -}}
max: >
{%- set ret = state_attr('sensor.openevse_rapi_gc', 'ret') -%}
{%- set rgx = '(?<=^\$OK )([0-9]+) +([0-9]+)' -%}
{%- set v = ret | regex_findall_index(rgx) -%}
{{- [16, v[1]|int]|min -}}
set_value:
- service: rest_command.openevse_rapi
data:
host: !secret OPENEVSE_HOST
rapi: >
$SC {{ value }} {{ '' if is_state('input_boolean.openevse_save_current', 'on') else 'V' }}
No luck, I think the rest_command is just not executing or at least not applying.
And this should lose the last part
set_value:
- service: rest_command.openevse_rapi
data:
host: !secret OPENEVSE_HOST
rapi: >
$SC {{ value }} {{ '' if is_state('input_boolean.openevse_save_current', 'on') else 'V' }}
and become
set_value:
- service: rest_command.openevse_rapi
data:
host: !secret OPENEVSE_HOST
rapi: >
$SC {{ value }}
According to GitHub - OpenEVSE/ESP8266_WiFi_v2.x: ESP8266 WiFi for OpenEVSE Version 2.x at least.
Ok figured out the issue, it’s a GET instead of POST even though the official docs above say it’s a POST
Almost done but, I am not seeing the value change on the UI.
So I change the value by dragging here and you can see behind it still shows 16 even though it was changed to 11 successfully.
Any idea why?
petro
(Petro)
November 8, 2021, 3:53pm
25
because it gets it’s state from
Correct and it looks like that value is the max value not the current one.
The correct value can be seen in this sensor here, the 13:
Any idea how to set the value of the number template to that?
petro
(Petro)
November 8, 2021, 5:21pm
27
did you make the min/max tempaltes?
No but they are also not needed, I set them to min 6 and max 16.
I believe this should do the trick for the state to give me that 3rd number:
{% set val = states('sensor.openevse_rapi_gc').split(' ')[3] %}
{{ val }}
Final result:
template:
- number:
- unique_id: openevse_max_current
name: Max Current
step: 1
state: >
{% set val = states('sensor.openevse_rapi_gc').split(' ')[3] %}
{{ val }}
availability: "{{ states('sensor.openevse_rapi_gc') not in ['unavailable','unknown'] }}"
min: 6
max: 16
set_value:
- service: rest_command.openevse_rapi
data:
host: !secret OPENEVSE_HOST
rapi: >
$SC {{ value|int }}
And all works as expected, many thanks for the assist.
1 Like