Example #1
0
def cli(ctx, ip: str, token: str, debug: int):
    """A tool to command Xiaomi Philips LED Ceiling Lamp."""

    if debug:
        logging.basicConfig(level=logging.DEBUG)
        _LOGGER.info("Debug mode active")
    else:
        logging.basicConfig(level=logging.INFO)

    # if we are scanning, we do not try to connect.
    if ctx.invoked_subcommand == "discover":
        return

    if ip is None or token is None:
        click.echo("You have to give ip and token!")
        sys.exit(-1)

    dev = mirobo.Ceil(ip, token, debug)
    _LOGGER.debug("Connecting to %s with token %s", ip, token)

    ctx.obj = dev

    if ctx.invoked_subcommand is None:
        ctx.invoke(status)
Example #2
0
import mirobo
import paho.mqtt.client as mqtt

print("Skrypt sterowania Philips Xiaomi LED Bulb")

# Inicjacja zarowki z biblioteki mirobo
led = mirobo.Ceil()

# Set MQTT Topic
setOnMQTT = "/home/setOn"
statusOnMQTT = "/home/statusOn"
setBrightnessMQTT = "/home/setB"
statusBrightness = "/home/statusB"
setColorTemperatureMQTT = "/home/setColor"
statusColorTemperature = "/home/statusColorTemperature"

# Metody Paho-MQTT


# Gdy polaczony
def on_connect(client, userdata, flasgs, rc):
    print("Connect with result code: " + str(rc))

    client.subscribe(setOnMQTT)
    client.subscribe(setBrightnessMQTT)
    client.subscribe(setColorTemperatureMQTT)


# Gdy odbiera wiadomosc
def on_message(client, userdata, message):
    if message.topic == setOnMQTT: