Exemplo n.º 1
0
def setup_platform(
    hass: HomeAssistant,
    config: ConfigType,
    add_entities: AddEntitiesCallback,
    discovery_info: DiscoveryInfoType | None = None,
) -> None:
    """Set up the beewi_smartclim platform."""

    mac = config[CONF_MAC]
    prefix = config[CONF_NAME]
    poller = BeewiSmartClimPoller(mac)

    sensors = []

    for sensor_type in SENSOR_TYPES:
        device = sensor_type[0]
        name = sensor_type[1]
        unit = sensor_type[2]
        # `prefix` is the name configured by the user for the sensor, we're appending
        #  the device type at the end of the name (garden -> garden temperature)
        if prefix:
            name = f"{prefix} {name}"

        sensors.append(BeewiSmartclimSensor(poller, name, mac, device, unit))

    add_entities(sensors)
Exemplo n.º 2
0
from beewi_smartclim import BeewiSmartClimPoller

b = BeewiSmartClimPoller("d0:5f:b8:51:9b:36")
b.update_sensor()

temperature = b.get_temperature()
humidity = b.get_humidity()
battery = b.get_battery()

print(temperature, humidity, battery)