firstof9 / openevse

OpenEVSE Integration for Home Assistant
MIT License
70 stars 12 forks source link

[Bug]: Manual Override and Sleep Mode does not work as in OpenEVSE UI #339

Open iRonin opened 6 months ago

iRonin commented 6 months ago

The problem

Also, Sleep Mode (new) does not seem to do anything. Please check my recording: https://www.dropbox.com/scl/fi/xunx6tg5in8262rp7n64d/OpenEVSE-sleep-override-isssue-240515.mov?rlkey=tco4ktgdv5kh8ah4fgn6arr9r&dl=0 Thanks.

What version of Home Assistant?

core-2024.5.3

What version of OpenEVSE?

8.2.2 & wifi v5.1.0_modified

Diagnostics information

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

firstof9 commented 6 months ago

Please don't use the switches for automations, use the service calls. The one you'll likely be using is openevse.make_claim in Home Assistant.

firstof9 commented 6 months ago

The toggles are working as they should, "Sleep Mode" means charging is disabled. When you change the status outside of the scheduled (auto) mode, that's an override, so that turns on.

Here's the API that's being used for reference: https://openevse.stoplight.io/docs/openevse-wifi-v4/e3153e2367cb1-open-evse-wi-fi-api

iRonin commented 6 months ago

make_claim is even more confusing as after making a claim from HA I cannot then use OpenEVSE UI to toggle charge… I guess I overestimated what's possible with OpenEVSE…

After make_claim my timers are gone and UI toggle charge reverses. I guess I should release the claims or something but again I prefer how the button works...

firstof9 commented 6 months ago

If you are charging based on solar output you should also be using the Solar PV divert, it'll adjust the available amps.

All you should really need to do is automate active and disabled via Home Assistant

iRonin commented 6 months ago

If you are charging based on solar output you should also be using the Solar PV divert, it'll adjust the available amps.

All you should really need to do is automate active and disabled via Home Assistant

The Solar PV divert is not what I'm looking for. I want to make sure home batteries charging is prioritized until they are, say, 95% full while consuming solar excess during the charging and then make sue I never discharge the batteries while ,charging. The reason we're using HA is to make all the automations work like we want and not how the manufacturers want us.

iRonin commented 6 months ago

The toggles are working as they should, "Sleep Mode" means charging is disabled. When you change the status outside of the scheduled (auto) mode, that's an override, so that turns on.

Here's the API that's being used for reference: https://openevse.stoplight.io/docs/openevse-wifi-v4/e3153e2367cb1-open-evse-wi-fi-api

I disagree because the override and sleep are somehow connected and as you can see on my video I cannot achieve the same state in the UI with integration switches.

Anyway, I think I have my logic done and will test it the following days.

Thank you for your work on this integration - it's always easier even though sometimes not everything is clear.

Perhaps mentioning integration services (openevse.make_claim etc) and providing link to OpenEVSE API in the README would save your time for issues like mine :)

firstof9 commented 6 months ago

Yes I haven't had much time to update the README just yet, it's on my to do list.

vermut commented 3 months ago

I noticed the thread and I think I'm having similar issue so maybe you can point me to a right solution.

I'm trying to switch between solar_divert and just max_charge. I can do PV->Full turning off PV, but turning PV on also turns on both sleep buttons effectively stopping the charge.

What is the right path here?

P.S. What are claims?

firstof9 commented 3 months ago

Here's the claims API: https://openevse.stoplight.io/docs/openevse-wifi-v4/221999f7bb3e5-list-evse-claims

Sleep only turns on when the EVSE is either commanded to sleep (via the toggle), or if it's set to an auto schedule and the schedule has it set to disable charging at a specific time.

vermut commented 2 months ago

When I touch divert both sleep follow that with 1s delay image

see that only first action was activated manually image

firstof9 commented 2 months ago

What are your PV divert settings set to in OpenEVSE?

vermut commented 2 months ago

This one? It's "Default".

image

firstof9 commented 2 months ago

So when you enable PV divert, that system's in control of sleeping the charger based on your settings there.

Digital-MoBa commented 2 months ago

If you toggle "Solar PV divert" switch it disable the self production. In the Web UI you can see that the ECO (Solar Symbol) is gone. This is what to expect when changing the configuration setting of self production.

To change ECO-Mode (disable/enable) you need to take the selection "openevse_divert_mode" and change fast to eco. I just need to remark that this could be done better by using a switch.

I think the most problem ist that the used update intervall for the integration is very so. That's why it's not possible to use the switch at all. For example if I flip the "Manual Override" from ON to OFF it toggle on the web-UI between AUTO-Mode and Disable Charge (sleeping) and the switch always stay in the ON-Position, because it belongs to the "openevse_divert_mode" selection! Just make it like it is on the web-UI, that is lesss complicated -> selection "Enable Charge" / "AUTO" / "disable Charge" (sleeping), a switch to toggle ECO (on/off), a switch to toggle the SHAPER (on/off) and one selection for the Current (here is also an fault: min current is 6A), nothing more.

It would be great if this switches work like in the web-UI and also uses the same names and also the update interval would be much faster so the reaction of changing is noticeable. Now it only updates the values after 4-5 minutes!

firstof9 commented 2 months ago

also the update interval would be much faster so the reaction of changing is noticeable

There is no update interval, the OpenEVSE pushes changes to HA.

Digital-MoBa commented 2 months ago

I just checked again the messages with MQTT-Explorer on the mosquitto broker that runs on my HA. There I can see all data in realtime. But the entities in the integration only change there values every 4-5 minutes. From where did the entities get there values - they are connect with the integration to the openevse IP and capture the data via tha API. Did the openevse API do push?

firstof9 commented 2 months ago

Did the openevse API do push?

Yes it pushes via websocket.

simonjowett commented 1 month ago

I'm in a similar position trying to relate the operation of the OpenEVSE web page with the various switches and select function in the Home assistant Integration. I can also report the delay in updating but I think this may be the HA scan rate? I agree with the comments above about 'eco' and 'fast', it would be easier with a switch (unless you know of future modes)! At present I think most people either want a fast charge or a managed one.

Sleep mode does not work (as previously commented) - very confusing.

Despite the criticisms, they are not meant negatively, I very much appreciate the work - please continue!

iRonin commented 1 month ago

@simonjowett I've been using this integration for quite some time and everything works but you have to use the claims.

firstof9 commented 1 month ago

HA scan rate?

There is no scan rate, states are pushed from the OpenEVSE over a websocket connection. It's real time.

Sleep mode does not work (as previously commented) - very confusing.

The sleep mode is mostly for backwards compatibility with older OpenEVSEs, please use the claims service call to manage sleep mode more effectively.

I agree with the comments above about 'eco' and 'fast', it would be easier with a switch (unless you know of future modes)!

These are the modes as set in the API. The OpenEVSE team may add additional modes, I'm not sure. What would everyone suggest a switch be named for this?

Digital-MoBa commented 1 month ago

I suggest that it should work like in the WebUI. Just leave the dropdown box and put all Mode inside: FAST, ECO, SLEEP. Leave a Switches for ECO-Mode to enable Solar divert and one to activate the Shaper. Write some IF statements to deactivate the divert and shaper switch when no ECO-Mode is selected in the dropdown. Remove all the rest switches, also the backwards compatibility ones, since they are confusing. With that you are also able to add easy additional new modes.

vermut commented 1 month ago

Yes, suggestion above made me understand, why this appeared like a bug to me. Indeed, webUI just has a button image

and I was instinctively looking for the same button in HA.

simonjowett commented 1 month ago

@simonjowett I've been using this integration for quite some time and everything works but you have to use the claims.

OK - I've taken a look at this and realized I had the wrong version of OpenEVSE installed in H.A. I've now upgraded to the latest version here and my apologies on previous comments as they were against this dev0.0.0 version. I've now started testing under "Developer Tools" and practicing with the H.A OpenEVSE service calls. Yes, I can confirm they work immediately, but I guess you knew that all along! Still, I need to wrap my brain around this, (what seems to me) a confusing array of options. I realize this range of options comes from the differing needs of each user alongside the different environments we find ourselves in in our home country (mine is Australia).

To explain the 2 main scenarios that I would like to happen:

1) Charge from excess solar (huge surplus from spring to autumn), charge during day and use PV divert function. 2) Charge from a 'controlled load', this is a cheap rate, and I use it sometimes in winter and the relay in the meter turns on at times during a 24hr period. In this instance I want charging to start when the OpenEVSE powers on and, given its at night, to charge at the full 32A rate.

Anyway, I'll do more work this coming w/e to see what I can automate.

firstof9 commented 1 month ago

Indeed, webUI just has a button

The API calls don't have an option for "auto", it would make things a bit easier.

KipK commented 1 month ago

In fact Auto means there's no manual override ( or claim if you use claims ) state property. Toggling Auto on HA will just need to clear this property.

firstof9 commented 1 month ago

Toggling Auto on HA will just need to clear this property.

Which is what toggling "Manual override" or "Sleep mode" does.

KipK commented 1 week ago

I'm trying to mimic the openevse UI 3 button selectors in home assistant. It's not possible to do it easily for now we would need a way to know if there's an override and what state the override has. Using current manual_override sleep_mode entity won't solve the problem of displaying correct icon colors for enabled and disabled.

Something that would solve it, would be to have a select entity with the 3 states:

edit: I've managed to do it using an automation that feed an input template input_text.openevse_override_state

image image image

automation:

alias: Update OpenEVSE State
description: Update OpenEVSE 3 buttons state
triggers:
  - entity_id: binary_sensor.openevse_manual_override
    trigger: state
  - type: changed_states
    device_id: 1a8619b7019b8e42ea0f560a0c008fc0
    entity_id: 2af9afd2bfe57f61f9d4a3127015f562
    domain: switch
    trigger: device
conditions: []
actions:
  - response_variable: openevse_response
    action: openevse.list_overrides
    data: {}
    target:
      device_id: 1a8619b7019b8e42ea0f560a0c008fc0
  - variables:
      override_state: "{{ openevse_response['state'] }}"
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ override_state == 'disabled' }}"
        sequence:
          - data:
              entity_id: input_text.openevse_override_state
              value: disabled
            action: input_text.set_value
      - conditions:
          - condition: template
            value_template: "{{ override_state == 'active' }}"
        sequence:
          - data:
              entity_id: input_text.openevse_override_state
              value: active
            action: input_text.set_value
    default:
      - data:
          entity_id: input_text.openevse_override_state
          value: auto
        action: input_text.set_value
mode: single

card yaml:

type: horizontal-stack
cards:
  - type: heading
    icon: ""
    heading_style: title
  - type: custom:button-card
    entity: input_text.openevse_override_state
    aspect_ratio: 2
    color_type: card
    show_label: true
    show_name: false
    icon: fas:bolt
    name: Auto
    tap_action:
      action: call-service
      service: openevse.set_override
      target:
        device_id: 1a8619b7019b8e42ea0f560a0c008fc0
      data:
        state: active
    state:
      - value: active
        color: rgb(24.71% 82.35% 56.47%)
        styles:
          icon:
            - color: >-
                [[[ if (states['sensor.openevse_charging_status.state'] ===
                'charging') return 'yellow';  else return 'white'; ]]]
      - operator: default
        color: rgba(0, 0, 0, 0.0)
        styles:
          icon:
            - color: rgba(24.71% 82.35% 56.47% 1)
    styles:
      card:
        - border-radius: 10%
  - type: custom:button-card
    entity: input_text.openevse_override_state
    aspect_ratio: 2
    color_type: card
    show_label: true
    show_name: false
    icon: fas:robot
    name: Auto
    tap_action:
      action: call-service
      service: openevse.clear_override
      target:
        device_id: 1a8619b7019b8e42ea0f560a0c008fc0
    state:
      - value: auto
        color: rgb(19.61% 70.2% 83.14%)
        styles:
          icon:
            - color: >-
                [[[ if (states['sensor.openevse_charging_status.state'] ===
                'charging') return 'yellow';  else return 'white'; ]]]
      - operator: default
        color: rgba(0,0,0,0.0)
        styles:
          icon:
            - color: rgba(19.61% 70.2% 83.14% 1)
    styles:
      card:
        - border-radius: 10%
  - type: custom:button-card
    entity: input_text.openevse_override_state
    aspect_ratio: 2
    color_type: card
    show_label: true
    show_name: false
    icon: fas:ban
    name: Auto
    tap_action:
      action: call-service
      service: openevse.set_override
      target:
        device_id: 1a8619b7019b8e42ea0f560a0c008fc0
      data:
        state: disabled
    state:
      - value: disabled
        color: rgb(6.67% 41.57% 53.33%)
        styles:
          icon:
            - color: white
      - operator: default
        color: rgba(0,0,0,0.0)
        styles:
          icon:
            - color: white
    styles:
      card:
        - border-radius: 10%
  - type: heading
    icon: ""
    heading_style: title
firstof9 commented 1 week ago

I'm trying to mimic the openevse UI 3 button selectors in home assistant. It's not possible to do it easily for now we would need a way to know if there's an override and what state the override has.

Have you tried the action: list_overrides ?

edit: nevermind you're using it.

KipK commented 1 week ago

Yes that's what I've done, see my edited topic above.

But it needs a template + an automation to achieve this. Not really UX friendly for some users. :)