コード例 #1
0
ファイル: tool.py プロジェクト: abschwar/PyGRBL
 def groupMills(self):
   '''Groups the toolpath into individual mills'''
   puts(colored.blue('Grouping paths:'))
   
   mill = Mill();
   for item in progress.bar(self):
     if item.cmd in (1,2,3):
       mill.append(item)
     else:
       if len(mill) > 0:
         self.mills.append(mill)
         mill = Mill() # ready for more mills
コード例 #2
0
async def async_setup_platform(hass, config, async_add_entities,
                               discovery_info=None):
    """Set up the Mill heater."""
    mill_data_connection = Mill(config[CONF_USERNAME],
                                config[CONF_PASSWORD],
                                websession=async_get_clientsession(hass))
    if not await mill_data_connection.connect():
        _LOGGER.error("Failed to connect to Mill")
        return

    await mill_data_connection.find_all_heaters()

    dev = []
    for heater in mill_data_connection.heaters.values():
        dev.append(MillHeater(heater, mill_data_connection))
    async_add_entities(dev)

    async def set_room_temp(service):
        """Set room temp."""
        room_name = service.data.get(ATTR_ROOM_NAME)
        sleep_temp = service.data.get(ATTR_SLEEP_TEMP)
        comfort_temp = service.data.get(ATTR_COMFORT_TEMP)
        away_temp = service.data.get(ATTR_AWAY_TEMP)
        await mill_data_connection.set_room_temperatures_by_name(room_name,
                                                                 sleep_temp,
                                                                 comfort_temp,
                                                                 away_temp)

    hass.services.async_register(DOMAIN, SERVICE_SET_ROOM_TEMP,
                                 set_room_temp, schema=SET_ROOM_TEMP_SCHEMA)
コード例 #3
0
async def async_setup_entry(opp, entry, async_add_entities):
    """Set up the Mill climate."""
    mill_data_connection = Mill(
        entry.data[CONF_USERNAME],
        entry.data[CONF_PASSWORD],
        websession=async_get_clientsession(opp),
    )
    if not await mill_data_connection.connect():
        raise ConfigEntryNotReady

    await mill_data_connection.find_all_heaters()

    dev = []
    for heater in mill_data_connection.heaters.values():
        dev.append(MillHeater(heater, mill_data_connection))
    async_add_entities(dev)

    async def set_room_temp(service):
        """Set room temp."""
        room_name = service.data.get(ATTR_ROOM_NAME)
        sleep_temp = service.data.get(ATTR_SLEEP_TEMP)
        comfort_temp = service.data.get(ATTR_COMFORT_TEMP)
        away_temp = service.data.get(ATTR_AWAY_TEMP)
        await mill_data_connection.set_room_temperatures_by_name(
            room_name, sleep_temp, comfort_temp, away_temp
        )

    opp.services.async_register(
        DOMAIN, SERVICE_SET_ROOM_TEMP, set_room_temp, schema=SET_ROOM_TEMP_SCHEMA
    )
コード例 #4
0
async def async_setup_entry(hass, entry):
    """Set up the Mill heater."""
    hass.data.setdefault(DOMAIN, {LOCAL: {}, CLOUD: {}})

    if entry.data.get(CONNECTION_TYPE) == LOCAL:
        mill_data_connection = MillLocal(
            entry.data[CONF_IP_ADDRESS],
            websession=async_get_clientsession(hass),
        )
        update_interval = timedelta(seconds=15)
        key = entry.data[CONF_IP_ADDRESS]
        conn_type = LOCAL
    else:
        mill_data_connection = Mill(
            entry.data[CONF_USERNAME],
            entry.data[CONF_PASSWORD],
            websession=async_get_clientsession(hass),
        )
        update_interval = timedelta(seconds=30)
        key = entry.data[CONF_USERNAME]
        conn_type = CLOUD

    if not await mill_data_connection.connect():
        raise ConfigEntryNotReady
    data_coordinator = MillDataUpdateCoordinator(
        hass,
        mill_data_connection=mill_data_connection,
        update_interval=update_interval,
    )

    hass.data[DOMAIN][conn_type][key] = data_coordinator
    await data_coordinator.async_config_entry_first_refresh()

    hass.config_entries.async_setup_platforms(entry, PLATFORMS)
    return True
コード例 #5
0
ファイル: __init__.py プロジェクト: MatthiasLohr/core
async def async_setup_entry(hass, entry):
    """Set up the Mill heater."""
    mill_data_connection = Mill(
        entry.data[CONF_USERNAME],
        entry.data[CONF_PASSWORD],
        websession=async_get_clientsession(hass),
    )
    if not await mill_data_connection.connect():
        raise ConfigEntryNotReady

    await mill_data_connection.find_all_heaters()

    hass.data[DOMAIN] = mill_data_connection

    hass.config_entries.async_setup_platforms(entry, PLATFORMS)
    return True
コード例 #6
0
ファイル: tool.py プロジェクト: michaelerickstad/PyGRBL
    def groupMills(self):
        '''Groups the toolpath into individual mills'''
        puts(colored.blue('Grouping paths:'))

        mill = Mill()
        for item in progress.bar(self):
            if item.cmd in (1, 2, 3):
                mill.append(item)
            else:
                if len(mill) > 0:
                    self.mills.append(mill)
                    mill = Mill()  # ready for more mills
コード例 #7
0
ファイル: mill.py プロジェクト: xwang345/home-assistant
async def async_setup_platform(hass,
                               config,
                               async_add_entities,
                               discovery_info=None):
    """Set up the Mill heater."""
    from mill import Mill
    mill_data_connection = Mill(config[CONF_USERNAME],
                                config[CONF_PASSWORD],
                                websession=async_get_clientsession(hass))
    if not await mill_data_connection.connect():
        _LOGGER.error("Failed to connect to Mill")
        return

    await mill_data_connection.update_heaters()

    dev = []
    for heater in mill_data_connection.heaters.values():
        dev.append(MillHeater(heater, mill_data_connection))
    async_add_entities(dev)
コード例 #8
0
async def async_setup_entry(hass, entry):
    """Set up the Mill heater."""
    mill_data_connection = Mill(
        entry.data[CONF_USERNAME],
        entry.data[CONF_PASSWORD],
        websession=async_get_clientsession(hass),
    )
    if not await mill_data_connection.connect():
        raise ConfigEntryNotReady

    hass.data[DOMAIN] = MillDataUpdateCoordinator(
        hass,
        mill_data_connection=mill_data_connection,
    )

    await hass.data[DOMAIN].async_config_entry_first_refresh()

    hass.config_entries.async_setup_platforms(entry, PLATFORMS)
    return True
コード例 #9
0
    async def async_step_user(self, user_input=None):
        """Handle the initial step."""
        if user_input is None:
            return self.async_show_form(
                step_id="user",
                data_schema=DATA_SCHEMA,
                errors={},
            )

        username = user_input[CONF_USERNAME].replace(" ", "")
        password = user_input[CONF_PASSWORD].replace(" ", "")

        mill_data_connection = Mill(
            username,
            password,
            websession=async_get_clientsession(self.hass),
        )

        errors = {}

        if not await mill_data_connection.connect():
            errors["connection_error"] = "connection_error"
            return self.async_show_form(
                step_id="user",
                data_schema=DATA_SCHEMA,
                errors=errors,
            )

        unique_id = username

        await self.async_set_unique_id(unique_id)
        self._abort_if_unique_id_configured()

        return self.async_create_entry(
            title=unique_id,
            data={
                CONF_USERNAME: username,
                CONF_PASSWORD: password
            },
        )