homeassistant-powercalc
homeassistant-powercalc copied to clipboard
[FR] Run playbook based on status (w/o service call)
Checklist
- [X] I have filled out the template to the best of my ability.
- [X] This only contains 1 feature request (if you have multiple feature requests, open one feature request for each feature request).
- [X] This issue is not a duplicate feature request of previous feature requests.
Is your feature request related to a problem? Please describe.
n/a
Describe the solution you'd like
I would love to have the option to run a playbook based on the status of the device, without the need of a start and stop service.
states:
idle: idle.csv
pause: pause.csv
off: off.csv
Every time the status changes, the playbook should start from the beginning
Describe alternatives you've considered
n/a
Additional context
A status change should stop the current running playbook and start the playbook mapped to the new state.
I will consider this. Do you use YAML or GUI?
Implemented with #2170
See: https://homeassistant-powercalc.readthedocs.io/en/latest/strategies/playbook.html#active-playbook-based-on-state-trigger
I cannot do for OFF
state as this is a special case in Powercalc, and needs fundamental changes on different places.
Will be in next release.
You could test it by installing the master branch with HACS.
@EddyK69 Ok, I only implemented in YAML yet. Will have a look if I can also implement for the GUI.
Thnx! That was a quick one! Is use the GUI btw. Will test this asap
Added for GUI with #2176
Thnx, but cannot download Master via HACS: get a 404 on https://github.com/bramstroker/homeassistant-powercalc/releases/download/master/powercalc.zip
That's strange it shouldn't try to download the release as it's not actually as release. Might be a bug in HACS. Pretty sure I was able to install this way in the past. Don't have time to investigate that further atm. Will do a new release for Powercalc soon.
Hi @bramstroker
I tried to download master many times, and it always failed with 404. I think the access right for that folder are restricted to your account. Maybe you can make the path to https://github.com/bramstroker/homeassistant-powercalc/releases/download/master/powercalc.zip
public readable?!
@erkr Strange you both are having issues. I cannot make that path available as master is not a release, but just the main branch where releases are made from. A zip file is only build when a new release / version is being issued. HACS shouldn't try to download powercalc.zip, but rather clone the repository. Maybe something changed in HACS why this is not working anymore, it was working in the past. I'll have a look.
I have found following issue on HACS issue tracker: https://github.com/hacs/integration/issues/3513
It was working in the past, but apparently it does not work anymore when the integration uses zip releases, which is what powercalc does and is the preferred way. According to the developer of HACS it's not something which will be fixed in HACS, which is a pitty. So there it not much I can do unfortunately.
If you want to you could download manually. And replace config/custom_components/powercalc
with the contents of custom_components/powercalc
. It's a littlebit more work, but it's essentially the same as HACS automates.
@bramstroker Great you found out that it simply doesn't work. I propose to just remove the master from the release list. You currently release so actively, that I can wait for the next one ☺️
I recall from another project that a version must be set in the manifest when you copy the files manually
@bramstroker Great you found out that it simply doesn't work. I propose to just remove the master from the release list. You currently release so actively, that I can wait for the next one ☺️
That not something I can fix in Powercalc, that's also a HACS issue.
When zip_release
is used they should just hide the master
branch from the list.
That's also suggested by other integration developers in the issue link I shared.
https://github.com/hacs/integration/issues/3513#issuecomment-1949471720
I recall from another project that a version must be set in the manifest when you copy the files manually
I'm pretty confident that's not required. You can just overwrite the files manually and restart and it should load the new code.
Today I'm with family, but I will give it a try tomorrow 👍
Added for GUI with #2176
@bramstroker I cannot find the settings in the GUI I'm afraid. Where can I find it?
@EddyK69 I see, there was actually a problem with the translation keys, causing the labels not correctly rendered. Will be fixed in next version.
The correct field is this one:
@bramstroker Thnx. Found the hidden field 😄
But unfortunately i cannot get it working the way i thought it should:
I configured a device with a simple on/off state:
And added 2 playbooks in de config/powercalc/playbooks folder:
cat test-on.csv
1,10
2,20
3,30
5,50
10,100
cat test-off.csv
1,100
2,50
3,30
5,20
10,10
The 'On' playbook seems to work, but the 'Off' playbook doesn't. After switching the device to Off, power is set to 0 immediately and after switching it On again, the playbook doesn't seem to start from the beginning:
https://github.com/bramstroker/homeassistant-powercalc/assets/13943630/c3482d27-86f6-4408-ab46-705086e774b0
I would expect that the playbook start over again after every state-change, right?
@EddyK69 Did you see one of my first comments after I implemented? https://github.com/bramstroker/homeassistant-powercalc/issues/2160#issuecomment-2027983565
off state cannot be used for playbook.
I will have a quick look if I can find a way to implement without needing to modify too much.
Have good news, because it was a quicky. Should be fixed with #2210
@EddyK69 Did you see one of my first comments after I implemented? #2160 (comment)
off state cannot be used for playbook.
Oops, missed that :|
Have good news, because it was a quicky. Should be fixed with #2210
Quick indeed! Wil try it again soon, thnx!
Have good news, because it was a quicky. Should be fixed with #2210
Quick indeed! Wil try it again soon, thnx!
Will be in next release. not sure when yet. maybe this weekend
Still doesn't seem to work unfortunately :(
https://github.com/bramstroker/homeassistant-powercalc/assets/13943630/43438603-14a6-4f7d-984b-799282689603
@EddyK69 You are sure you are at v1.11.8 now? Or are you running beta version of powercalc?
@EddyK69 You are sure you are at v1.11.8 now? Or are you running beta version of powercalc? @bramstroker Yep, I'm sure.
It worked once: switching ON started started to increase the power (see below how the playbooks are defined) and switiching OFF started to decrease, only once! After the OFF playbook was finished, i switched ON & OFF and nothing happens. I tried to restart the integration but that did not fix it.
cat test-on.csv
1,10
2,20
3,30
5,50
10,100
cat test-off.csv
1,100
2,50
3,30
5,20
10,10
Ok thanks for the extra information. Will have a look if I can reproduce and fix.
Should be fixed with #2229. According to the unit tests this should fix the issue. I'll also do some testing on my develop HA instance.
Ok thanks for the extra information. Will have a look if I can reproduce and fix.
Thnx! Just updated to V1.12.0 and it seems that is now not starting the OFF-playbook anymore :(
It's working for me now:
https://github.com/bramstroker/homeassistant-powercalc/assets/2345875/91fe1fcc-c441-4a88-b6fa-0b7e01200ca3
You can try by editing config/custom_components/powercalc/strategy/playbook.py
and add following to line 95:
https://github.com/bramstroker/homeassistant-powercalc/blob/09f2feca624ed8f772d6f3d504ed8786c330a172/custom_components/powercalc/strategy/playbook.py#L95
Restart HA afterwards.
Thanx @bramstroker for the quick fix! Wil try out this weekend
Yep, works perfectly now! Thanx @bramstroker !