BottlecapDave / HomeAssistant-OctopusEnergy

Unofficial Home Assistant integration for interacting with Octopus Energy
https://bottlecapdave.github.io/HomeAssistant-OctopusEnergy/
MIT License
570 stars 57 forks source link

Update Target Rate Service template or entity support #888

Closed mikihacia closed 4 months ago

mikihacia commented 4 months ago

Describe the feature

Would be great to have availability to update the target hours or other input fields when calling the service with the use of either templates or other entities.

image

Expected behaviour

Have an option to inject a template or entity to the target hours of the service.

Use Case

Handful when trying to charge a car and find the best rates based on the requried time to charge. If I need to charge the car today only for 3 hours, I want to find the best rates only for that time, cause next day I may need to charge it for 6 hours.

Confirmation

BottlecapDave commented 4 months ago

Hello. This should already be possible and is something provided by HA and not configurable by the integration. You might have better luck by changing your template to the following

"{{ states('sensor.charging_time_required') }}"

The error that is being displayed suggests that the state value you've specified either doesn't exist or is not a valid hours number, so you might want to double check this.

mikihacia commented 4 months ago

Hi,

The required format is a follows:

data: target_hours: "\"{{ states('sensor.charging_time_required') }}\""

It cannot be pasted in the UI, must be done in YAML and "\ ...CODE... \" is needed.

Thanks for pointing to the right way!