dan-r / HomeAssistant-Ohme

Unofficial Home Assistant integration for interacting with Ohme EV chargers (EVSE) 🚗⚡️
MIT License
43 stars 12 forks source link

Schedule integration plans #12

Closed brutus6 closed 9 months ago

brutus6 commented 9 months ago

Thanka for this. Just wondering, is schedule integration just not possible with Ohme's API or are they on the roadmap to be added? In particular setting departure time and days and setting added range percentage?

dan-r commented 9 months ago

Definitely possible, I haven't done it yet as I'm not sure how best to map schedules to Home Assistant entities.

Session specific adjustments are relatively straightforward as we can just say "I want to be at 80% by 9am" and update the current session (like you can in the app with 'change target'), but as soon as you unplug the car its gone. The fact its possible to have multiple schedules complicates editing them.

brutus6 commented 9 months ago

Thanks. To be compatible with tariffs like Intelligent Octopus Go it would need to be a preset schedule and not a session specific rule. Would be good if this could be set via Home Assistant and then when you plug in, it gets the requested mapping form Octopus. I myself don't have an API connected car so have to set a schedule each time via the Ohme App and I would love to be able to control that via Home Assistant. Great work anyway on this one.

dan-r commented 9 months ago

I'll have a play around with the API, I believe the 'schedules' are just 'charge to x% by time', so it shouldn't cause a problem with IO, but I can test with that as I'm on it too.

brutus6 commented 9 months ago

Cool... Ah glad your on IO as well. That will help with development. I understand what you mean with the multiple schedules causing an issue, but even if it can control the first schedule in the list that would be beneficial as most people on IO using the Ohme Integration with Octopus should only have one active schedule.

dan-r commented 9 months ago

@brutus6 I've added target time and percentage inputs to v0.2.6. These won't touch your set schedules but will do effectively the same as clicking 'change target' in the app and moving the slider/time setting on there.

Does this cover all the uses you need?

Dan

brutus6 commented 9 months ago

Thank you for what you have done so far on this. I have seen the latest release. Upon initial inspection, unfortunately, I don't think it will work for my specific use case in relation to Intelligent Octopus.

I will test it later, but it looks like you can only make the change to the percentage or the departure time after you have already plugged in and got a mapped charge from Octopus. Interestingly, there must be some connection to the schedules as it automatically knows my current set schedule percentage and departure time and displays that in HA by default. Perhaps from my last charge session?

I am specifically looking to edit the schedule for two reasons.

1) Adjusting the percentage or departure time after plugging in (session-specific rules), I am led to believe, can result in errors with the IOG and Ohme comms and result in peak charges sometimes. I understand that it is always best to set the targets prior to plugging in.

2) I am hoping to connect Android Auto to it via Home Assistant so I can program percentages from the car with the HA quick buttons before I get out and plug in to avoid needing to use the app, if I can help it. I can also then do that with voice via Google Assistant or Alex etc.

I understand there are challenges with this as Ohme supports multiple schedules, which can be named anything. Just an idea, not sure if it is possible, but would you be able to either have:

A) an entity that always changes the "first" schedule in the list B) or an entity that affects a specially named schedule (e.g. a schedule named 'Home Assistant'), then users that use HA just have to name their schedule in the Ohme app for it to connect up.

Thanks again for all your work on this project. Interested to hear your thoughts. I will let you know how the tests go. Thanks.

dan-r commented 9 months ago

Those two inputs read from and set the session specific charge schedule. From my testing, it doesn't seem to cause any issues with IOG if you change an ongoing session, but I understand why you'd want to change them beforehand.

Changing the first schedule seems like the most useful and easiest to implement. I'll give it a go and report back :)

brutus6 commented 9 months ago

Thanks Dan

dan-r commented 9 months ago

@brutus6 so I've got modifying schedules working (just takes the first one from the list), but being a bit indecisive on the user-facing implementation.

I've currently got it so the target time and percentage fields:

Not sure if this is a good approach or if it would be better to have seperate "scheduled percentage/time" inputs.

Dan

brutus6 commented 9 months ago

That sounds like a good approach on paper to me. Surely that gives people the best of both options and makes it less confusing with only one set of inputs to edit within HA. It essentially makes the existing inputs work even when the car is not plugged in. If I am understanding you correctly.

dan-r commented 9 months ago

Right, I've put out v0.2.8 which adds that. I've given it a quick test with my car but as always I'd appreciate you giving it a go!

I'm still not 100% on that approach with the inputs but can always revisit it later if it ends up confusing people!

Dan

brutus6 commented 9 months ago

Just installed the new version. It works just as I envisaged it. Thanks. I will run with it for a bit and let you know if I find it confusing. Cheers.

dan-r commented 9 months ago

I'll close this off for now - if you have any more thoughts or issues with it, feel free to re-open this or start a new issue.

Dan

andyvee69 commented 9 months ago

Being a pain here .. Just tried this for the first time. Plugged in and pending approval. Altering charge % resulted in it amending the current session (which wasn't active yet ..) and ending up with Session Specific Rule and it approving the charge, with a completely different end time to the schedule.

This wasn't what I expected, but may have misunderstood. Whilst Pending Approval I expected the first saved schedule to be amended, not the current session?

brutus6 commented 9 months ago

Ah, good spot, @andyvee69 - I didn't spot that, as my tests were done without the approved charge ticked. I don't tend to use that myself.

However, @dan-r I have also noticed that if you edit the percentage or the ready by time in the Ohme app, that isn't reflected in the HA entities number.ohme_target_percent nor time.ohme_target_time - again not a major issue for me (with my specific use case), but probably would be classed as not expected behaviour.

brutus6 commented 9 months ago

So, a bit more information. Unless I am mistaken. It seems that if, say, you edit the time in the app, it doesn't reflect in HA at first or after a few mins of waiting; however, if you then edit, say, the percentage in the app, the time does then update, so that seems to force a sync, but the sync doesn't seem to happen automatically, unless something changes inside Home Assistant. Hope that makes sense.

dan-r commented 9 months ago

Just tried this for the first time. Plugged in and pending approval. Altering charge % resulted in it amending the current session (which wasn't active yet ..) and ending up with Session Specific Rule and it approving the charge, with a completely different end time to the schedule.

@andyvee69 Ah yes I thought that could be a problem... I'll need to check that Ohme read the schedule at the point of approval rather than at the point of plug-in, but if this is the case I'll make it so the schedule is updated if pending.

Unless I am mistaken. It seems that if, say, you edit the time in the app, it doesn't reflect in HA at first or after a few mins of waiting

@brutus6 currently the schedules are only pulled every 10 minutes if not charging (OhmeChargeSchedulesCoordinator), or every 30s if you are charging (OhmeChargeSessionsCoordinator). Could you try doing this then waiting 10 mins? I set it this way because it didn't seem like much point pulling that info more regularly.

Dan

brutus6 commented 9 months ago

Ah that makes sense. Sorry, I did wonder if there was a delay (like the 1-minute delay on the buttons), but obviously didn't wait long enough. Makes sense. I will double-check, but I am sure you're right, and I just didn't wait long enough.

dan-r commented 9 months ago

No worries - I havent checked that it does in fact update after 10 mins, but it should™

andyvee69 commented 9 months ago

I'll need to check that Ohme read the schedule at the point of approval rather than at the point of plug-in

They do. It is one of the many advantages of using approve each plug in. You can plug in, go inside, then amend and save the schedule. Then Approve.

dan-r commented 9 months ago

@andyvee69 if you're in a position to test, v0.3.1-beta.1 is up. Not home so haven't had a change to test this at all. If using HACS, I think you have to go into the integration listing, click redownload > show beta versions.

andyvee69 commented 9 months ago

Will update now and then test later

andyvee69 commented 9 months ago

No worries - I havent checked that it does in fact update after 10 mins, but it should™

Doesn't seem to

andyvee69 commented 9 months ago

@andyvee69 if you're in a position to test, v0.3.1-beta.1 is up

Seems to work fine - plugged in, amended amount of charge, approved.

Worked as it should, amended the schedule, and the Ohme app is showing the Schedule rather than Session Specific Rule

brutus6 commented 9 months ago

Yeah seems to get stuck unless you edit either the time or percentage, and then that seems to force the sync and then the other does update a few seconds later. That is on V0.2.8, I will install the latest version and check again.

dan-r commented 9 months ago

Worked as it should, amended the schedule, and the Ohme app is showing the Schedule rather than Session Specific Rule

Good to hear. Were you able to test if the session specific setting remains working too? I'll give it a proper go before I promote the release later too

that seems to force the sync and then the other does update a few seconds later

Yeah that's to be expected - when you change either of the values it pulls the latest version of the rule, changes what it needs to then pulls the latest state after the update. I'll see if I can replicate the state getting stuck

andyvee69 commented 9 months ago

Were you able to test if the session specific setting remains working too

Yes, that seems to work as well

dan-r commented 9 months ago

I've just published v0.3.1, seems to be working well for me but would appreciate if you could test it.

Dan

andyvee69 commented 9 months ago

Already plugged in, will test tomorrow

brutus6 commented 9 months ago

This seems to be syncing okay now.

dan-r commented 9 months ago

Good to hear, thanks again!

andyvee69 commented 9 months ago

This seems to be syncing okay now.

Agreed.