Example #1
0
def setup():
    """This function is not working"""
    print('Setup option is not working')
    quit()
    print('Long press the reset button until the blue Led is blinking quickly')
    print('Long press again until blinking slowly')
    print('Manually connect this device to the Wifi SSID named BlroadlinkProv')
    print(
        'Press security mode (0 = none, 1 = WEP, 2 = WPA1, 3 = WPA2, 4 = WPA1/2)'
    )
    print('Default:3')

    security = raw_input('Security mode:').lower()

    if security == 'none':
        security = 0
    elif security == 'wep':
        security = 1
    elif security == 'wpa1':
        security = 2
    elif (security == 'wpa2') or (security == ''):
        security = 3
    elif security == 'wpa1/2':
        security = 4
    security = int(security)
    if not (0 <= security <= 4):
        raise IndexError

    ssid = raw_input('SSID of your router :')
    if security != 0:
        password = raw_input('Password:'******''
    broadlink.setup(ssid, password, security)
def setup():
    try:
        essid = request.args.get('essid')
        wifipass = request.args.get('wifipass')
        broadlink.setup(essid, wifipass, 4)
        return "{'data':'1'}"
    except:
        return "{'data':'0'}"
Example #3
0
    async def async_hysen_set_wifi(thermostat, service):
        ssid = service.data.get(CONF_WIFI_SSID)
        password = service.data.get(CONF_WIFI_PASSWORD)
        sectype = service.data.get(CONF_WIFI_SECTYPE)
        timeout = service.data.get(CONF_WIFI_TIMEOUT)
        try:
            broadlink.setup(ssid, password, sectype)
        except Exception as error:
            _LOGGER.error(
                "Failed to send Wifi setup to Broadlink Hysen Device(s):%s",
                error)
            return False
        _LOGGER.warning("Wifi setup to Broadlink Hysen Device(s) sent.")
        try:
            devices = broadlink.discover(timeout)
            devicecount = len(devices)
            if devicecount > 0:
                for device in devices:
                    if device.devtype == 0x4EAD:  # Hysen device ID
                        divicemac = ''.join(
                            format(x, '02x') for x in device.mac)
                        revmac = [
                            divicemac[i:i + 2]
                            for i in range(0, len(divicemac), 2)
                        ]
                        stringmac = revmac[5] + ":" + revmac[4] + ":" + revmac[
                            3] + ":" + revmac[2] + ":" + revmac[
                                1] + ":" + revmac[0]

                        _LOGGER.warning(
                            "Discovered Broadlink Hysen device : %s, at %s",
                            stringmac, device.host[0])
            else:
                _LOGGER.warning("No Broadlink Hysen device(s) found.")
        except Exception as error:
            _LOGGER.error("Failed to discover Broadlink Hysen Device(s):",
                          error)
            return False
        return True
Example #4
0
 def setting(self, SSID, password, security=3):
     broadlink.setup(SSID, password, security)
     return broadlink.discover(
         timeout=5)  #if not found return empty list []
if args.device:
    values = args.device.split()
    type = int(values[0], 0)
    host = values[1]
    mac = bytearray.fromhex(values[2])
elif args.mac:
    type = args.type
    host = args.host
    mac = bytearray.fromhex(args.mac)

if args.host or args.device:
    dev = broadlink.gendevice(type, (host, 80), mac)
    dev.auth()

if args.joinwifi:
    broadlink.setup(args.joinwifi[0], args.joinwifi[1], 4)

if args.convert:
    data = bytearray.fromhex(''.join(args.data))
    durations = to_microseconds(data)
    print(format_durations(durations))
if args.temperature:
    print(dev.check_temperature())
if args.energy:
    print(dev.get_energy())
if args.sensors:
    try:
        data = dev.check_sensors()
    except:
        data = {}
        data['temperature'] = dev.check_temperature()
Example #6
0
import broadlink
import ipdb

from my_credits import (
    WIFI_SSID,
    WIFI_PASSWORD,
    WIFI_SECIRITY_MODE,
)
from commands import (
    SAMSUNG_TV_POWER,
    SAMSUNG_TV_ADD_SOUND,
    SAMSUNG_TV_REDUCE_SOUND,
    SUMSUNG_TV_NEXT_CNANNEL,
    SUMSUNG_TV_PREVIOUS_CNANNEL,
)


broadlink.setup(WIFI_SSID, WIFI_PASSWORD, WIFI_SECIRITY_MODE)


try:
    print(f"Broadlink {WIFI_SSID} {WIFI_PASSWORD} {WIFI_SECIRITY_MODE}")
    device = broadlink.discover(timeout=10)[0]
    device.auth()
except IndexError:
    print("Broadlink is turned off")

ipdb.set_trace()