markgdev / home-assistant_OctopusAgile

Octopus Agile custom component for Home Assistant
Apache License 2.0
86 stars 33 forks source link

Can a "Moneymaker" be an "input. boolean"? #80

Closed GGW42 closed 2 years ago

GGW42 commented 3 years ago

Describe the bug I have been using your "home-assistant_OctopusAgile" custom integration successfully for over 6 months now (I am running the latest version) and have just been writing a Home Assistant Automation to enable me to disable the boiler when I go away in a few weeks (my first break in 18 months thanks to Covid19 restrictions). To do this I had to stop "home-assistant_OctopusAgile" from controlling the boiler switch directly, and control it via an "input. boolean" & an automation instead.

At first I though I could leave the Moneymaker set to the switch.boiler, since I didn't mind heating the water if I was being paid to do so :-) but found that doing so would turn off the switch.boiler as soon as my automation turned it on via input_boolean.boiler, mostly anyway, it depended on which one occurred first which is Logical enough with hind site.

So I then turned the moneymaker into an "input. boolean" as well, but since doing so the timers would not update and give this as part of the error message in the LOGS File "/config/custom_components/octopusagile/__init__.py", line 192, in handle_update_timers moneymaker = next(iter(moneymaker_dict.items())) AttributeError: 'str' object has no attribute 'items'

So I have now commented out the money makers completely to allow my "home-assistant_OctopusAgile" to run correctly with my input_boolean and Automation in place and my "AWAY" condition simply stops automation from turning the switch.boiler on when activated.

My code with a commented out lines for the alternate version of the boiler switch. moneymakers: - switch.boiler #- input_boolean.boiler

timers: - day_from: today day_to: tomorrow #entity_id: switch.boiler entity_id: input_boolean.boiler

To Reproduce Change the moneymakers: to be an input_boolean as shown above.

Expected behavior I expected the input_boolean to behave the same way as a switch

Desktop (please complete the following information):

Hopefully someone can tell me what I am doing wrong if this turns out to be "Just Me". Thanks for the code and your time, it is getting better all the time.

GGW42 commented 3 years ago

Hi All, I am back from Holidays now and I was hoping for someones comment on this but I guess everyone else is on holidays too. I looked at this again on my return and discovered my mistake.

I had omitted the ":null" parameter on the "Money Maker" entities. Once the ":null" with this it seems to work OK but I can't really tell till we get some period of zero pence power, it has been is a long time since we have seen one of those.

  moneymakers: 
  - input_boolean.boiler: null 
  timers:
  - day_from: today
    day_to: tomorrow
    entity_id: input_boolean.boiler

I don't suppose anyone knows why the ":null" is needed there and nowhere else? Are there any other options than null? If so can someone please tell me the syntax of the other options?

markgdev commented 2 years ago

@GGW42 sorry for the delay, you can either have null or just leave the ":" on it's own. I have the later in my config:

moneymakers:
  - input_boolean.hot_water_on:

A note for when I have more time. This is caused by this line The config is expected to be a dict by default to allow extra params to be set. Need to change this so that it checks if the config is a dict or str.

GGW42 commented 2 years ago

OK, Thanks for your help, makes sense now.