Skip to content

withenergy construction option, get_homes() get_devices() get_energy() methods#7

Open
lupus78 wants to merge 1 commit intoDanielhiversen:mainfrom
lupus78:main
Open

withenergy construction option, get_homes() get_devices() get_energy() methods#7
lupus78 wants to merge 1 commit intoDanielhiversen:mainfrom
lupus78:main

Conversation

@lupus78
Copy link

@lupus78 lupus78 commented Nov 6, 2023

withenergy construction option, if True, the ?withEnergy=1 query is used on /content/ endpoint.

get_homes()
get_devices()
get_energy() methods

I just wanted to monitor the energyWh data points, ended up adidng a withenergy parameter to contrstuctor, and the about 3 getters

…sed on /content/ endpoint.

get_homes()
get_devices()
get_energy() methods
@Danielhiversen
Copy link
Owner

Is that different than the energy data from fetch_energy_info?

async def fetch_energy_info(self):

@lupus78
Copy link
Author

lupus78 commented Nov 13, 2023

Is that different than the energy data from fetch_energy_info?

async def fetch_energy_info(self):

Not the same. This one is a log for each device and aggregate by hours. The one with the content endpoint is by Room and for the last hour.

As you can see the Blue line is from the content?withEnergy endpoint. I query it every 10 minutes, and you can see it's progressing throughout the hour and resets.
The pink line is from the energy_log (I also ran that 10 minutes and always pick the last data), I think it's shifted this was, but you can see it almost alines with the hourly tops.
image

@Danielhiversen
Copy link
Owner

So the energy data is then stored in self._devices ?

@lupus78
Copy link
Author

lupus78 commented Nov 13, 2023

So the energy data is then stored in self._devices ?

yes

@@ -104,13 +122,18 @@ async def _write_set_room_target_temperature(self, json_data):

async def fetch_rooms_info(self):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to add an include_energy parameter and then remove self.withenergy

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the current structure that would mean to pass it down from get_room and update

self._write_task = None
self._pending_writes = {"rooms": []}

async def get_homes(self):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to not do self.update() in all these functions. Should be possible to get self._homes without forcing an update.
(Should not had self.update() in get_rooms either)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't wanted to such refactor. Imho, the cleanest would be to have functions which are 1-on-1 with the API endpoints.

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

Successfully merging this pull request may close these issues.

2 participants