File: shade.py

package info (click to toggle)
python-aiopvapi 3.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 684 kB
  • sloc: python: 3,123; xml: 850; makefile: 5
file content (18 lines) | stat: -rw-r--r-- 642 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from aiopvapi.helpers.aiorequest import AioRequest
from aiopvapi.resources.shade import factory
from aiopvapi.shades import Shades, ATTR_SHADE_DATA


class ExampleShade:
    def __init__(self, hub_ip):
        self.request = AioRequest(hub_ip)
        self.shades = []
        self._shades_entry_point = Shades(self.request)

    async def get_shades(self):
        _shades = await self._shades_entry_point.get_resources()
        for shade in _shades[ATTR_SHADE_DATA]:
            self.shades.append(factory(shade, self.request))

    async def get_shade(self, shade_id):
        return await self._shades_entry_point.get_instance(shade_id)