Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sensors #56

Open
lewiscf77 opened this issue Feb 5, 2021 · 12 comments
Open

Sensors #56

lewiscf77 opened this issue Feb 5, 2021 · 12 comments

Comments

@lewiscf77
Copy link

Describe the bug
Hi sorry if this is wrong place, I'm new to HA and am trying to get this working to charge the car.

I may have configured this incorrectly but I can't see how to configure the sensors.

In the readme it ends here.
sensor:

platform: "octopusagile"
To Reproduce
My config.yaml.

run_devices:

energy_time: 2.5
entity_id: switch.office_heater
run_before: '08:00:00'
sensor:
platform: "octopusagile"

Expected behavior
Sensors show in HA

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context
Add any other context about the problem here.

@markgdev
Copy link
Owner

markgdev commented Feb 5, 2021

Hi @lewiscf77, do you have any errors in the home assistant log file that might help narrow it down? Are you seeing any of the octopusagile entities? A formatted version of your config for the component would be useful too (Minus your account details)

@lewiscf77
Copy link
Author

lewiscf77 commented Feb 8, 2021 via email

@markgdev
Copy link
Owner

markgdev commented Feb 8, 2021

Hi @lewiscf77,
Sounds like it’s nearly there. Your config looks good at a quick scan over. To confirm, you’re seeing octopusagile.timers get populated with your switch and times? If so, try calling the octopusagile.half_hour service from the developer tools. While you run it, have a look at the log and see if you see any errors. You can also edit the times on the timers entity in developer tools so that you don’t have to wait until one of your timers triggers to test.
Let me know how you get on!
Mark

@GGW42
Copy link

GGW42 commented Feb 22, 2021

Hi @lewiscf77
I was just wondering if you got this working?
I did a 24hour test of my setup because I was fairly sure I saw an error in you configuration, as I had done a similar thing myself before and wanted to remind myself of what happened at that time.

I think your error is in the < run_devices: > section because it doesn't seem to work if you put an actual device entity in there,
by way of example I have this device for my washing machine, under run_devices:

- energy_time: 0.5 entity_id: washing_machine run_before: '08:00:00' run_time: 0.5
The above YAML creates an entity called 'octopusagile.washing_machine' I then use an Automation to control the actual switch.

Replacing the entity_id: washing_machine with an actual switch (in my case 'switch.sinotimer_switch' that I use for testing) seems to stop both the timer & run device from working, nothing ever happens.
Mark may know why, I have no clue but the logs do say this:-

Logger: custom_components.OctopusAgile Source: custom_components/OctopusAgile/__init__.py:355 Integration: OctopusAgile First occurred: 21 February 2021, 15:30:05 (53 occurrences) Last logged: 17:30:04 Invalid entity id encountered: octopusagile.switch.sinotimer_switch. Format should be <domain>.<object_id>

So perhaps I need to replace the second '.' with an '_' in the switch name? Not sure, but I haven't yet successfully got an actual switch to work there.

The timers section originally had the opposite problem in that the entity had to be a switch but mark changed that some months ago to allow 'input_boolean' instead of a switch and I use that for a second timer to trigger an Automation.

@markgdev FYI. The timers did get updated and looked like they should work but all failed last night, just as well the weather is warmer then last week :)
`timers:

  • entity_id: switch.boiler_disabled_enabled
    times:
    '2021-02-21T22:30:00Z':
    params: null
    rate: 9.261
    '2021-02-22T04:30:00Z':
    params: null
    rate: 9.639
    '2021-02-22T14:00:00Z':
    params: null
    rate: 9.702
    '2021-02-22T14:30:00Z':
    params: null
    rate: 8.925
    '2021-02-22T15:00:00Z':
    params: null
    rate: 9.702`

OK that's my view and I probably got a lot wrong but that's how it seems to work for me.

As a test just comment out that run device and I suspect your car will start charging.

Mark, feel free to point out any mistakes i have made, i am still learning HA and all the stuff that goes with it.

@lewiscf77
Copy link
Author

lewiscf77 commented Feb 23, 2021 via email

@GGW42
Copy link

GGW42 commented Feb 23, 2021

Craig, you could just set a block time by changing the Block option to true, it will then allow find the cheapest block of hours (depending on your needs) and keep it switched on for that period each time.
Shown in my example below is 2 x 3hour blocks.

block: true    #(Optional, note that if requirements are set, the block times will be taken from there.)
    requirements:
      - day_from: today
        day_to: tomorrow
        numHrs: 3
        time_from: '19:00:00'
        time_to: '09:00:00'
      - day_from: tomorrow
        day_to: tomorrow
        numHrs: 3
        time_from: '10:00:00'
        time_to: '16:00:00'

This works quite well.

@lewiscf77
Copy link
Author

lewiscf77 commented Feb 25, 2021 via email

@derekcfoley
Copy link

Recently my HASS setup was updated, and your code no longer seems to work, I had to reinstall HACS and I reinstalled your code for Agile, yet I'm not able to get anything working. specifically the "current price".

image

I've gone back through and checked everything - obviously I put my account details into the configuration.yaml.

Is there something missing from the configuration - I'm wondering if there is something missing in the documentation and example config code - as it mentions:

"sensor
Create a sensor for each of: current rate, previous rate and next rate"

Yet there isn't an example of this, only a sample configuration yaml with at the end a single entry of:

sensor:
- platform: "octopusagile"

@markgdev
Copy link
Owner

Yet there isn't an example of this, only a sample configuration yaml with at the end a single entry of:
This is all that you need for the sensors.

I've updated HA today and tried to see if I could get the same issue but haven't been able to replicate. Did it sort itself out in the end? If you see it again, try running octopusagile.update_timers and then wait for the half hour to tick over and hopefully you'll be good to go. If not throw any errors you have in your log on here and I'll take a look.

@markgdev
Copy link
Owner

Hi, I now have this working pretty much as I want and it's awesome. Using the timers to call a hook switch that I use the state within node red to call a flow. This probably the correct place for this (being a newby I apologise if it's not)! Is it possilbe to change how "money makers" work. I'd like to set a low value say <4p to switch on, not just when it's negative. I've tried to find how to do it myself but with no joy. Craig

@lewiscf77 Sounds feasible to me, I'm not sure I'll get time anytime soon though but if you want to give it a go. I think a copy of the moneymakers section would work and change the 0 on this line to 4.

@bobbinz
Copy link

bobbinz commented Jul 18, 2021

Recently my HASS setup was updated, and your code no longer seems to work, I had to reinstall HACS and I reinstalled your code for Agile, yet I'm not able to get anything working. specifically the "current price".

I just installed and get exactly the same thing, I can't get price info!

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 401, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 609, in async_device_update raise exc File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/octopusagile/sensor.py", line 159, in update current_rate = self.hass.states.get("octopusagile.all_rates").attributes.get(rounded_time_str) AttributeError: 'NoneType' object has no attribute 'attributes'

@bobbinz
Copy link

bobbinz commented Jul 18, 2021

Oh no, I lied!

I just needed to be more patient and wait for the values to load after a half hour tick around!

Sorted!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants