File: timer.py

package info (click to toggle)
python-aiopulse 0.4.5-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 180 kB
  • sloc: python: 1,173; makefile: 4
file content (34 lines) | stat: -rw-r--r-- 904 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""Elements that hang off the hub."""
from typing import List, Callable

import aiopulse.utils as utils
import aiopulse.const as const
import asyncio


class Timer:
    """Representation of a Timer."""

    def __init__(self, hub, timer_id):
        """Init a new timer."""
        self.hub = hub
        self.id = timer_id
        self.icon = None
        self.name = None
        self.state = None
        self.hour = None
        self.minute = None
        self.days = None
        self.entity = None

    def __str__(self):
        """Returns string representation of timer."""
        return (
            f"Name: {self.name} "
            f"ID: {self.id[0:4]} "
            f"Icon: {self.icon} "
            f"State: {self.state} "
            f"Time: {self.hour}:{self.minute} "
            f"Days: {self.days:>07b} "
            f'Entity: {self.entity.name if self.entity else "None"}'
        )