def setup_platform(hass, config, add_entities, discovery_info=None):
    import pybmr

    base_url = config.get(CONF_BASE_URL)
    user = config.get(CONF_USERNAME)
    password = config.get(CONF_PASSWORD)

    bmr = pybmr.Bmr(base_url, user, password)
    sensors = [
        BmrControllerHDO(bmr),
    ]

    add_entities(sensors)
示例#2
0
def setup_platform(hass, config, add_entities, discovery_info=None):
    import pybmr

    base_url = config.get(CONF_BASE_URL)
    user = config.get(CONF_USERNAME)
    password = config.get(CONF_PASSWORD)

    bmr = pybmr.Bmr(base_url, user, password)
    sensors = []
    for circuit_config in config.get(CONF_CIRCUITS):
        sensors.append(BmrCircuitTemperature(bmr, circuit_config))
        sensors.append(BmrCircuitTargetTemperature(bmr, circuit_config))

    add_entities(sensors)
示例#3
0
def handle_dump(args):
    config_data = {"circuits": [], "circuit_schedules": [], "schedules": []}

    # Connect to BMR HC64 controller
    bmr = pybmr.Bmr(*parse_url(args["url"]))

    # Low mode assignments
    low_mode_assignments = bmr.getLowModeAssignments()

    # Summer mode assignments
    summer_mode_assignments = bmr.getSummerModeAssignments()

    # Circuits and schedule assignments
    for circuit_id in range(bmr.getNumCircuits()):
        circuit = bmr.getCircuit(circuit_id)
        config_data["circuits"].append({
            "id":
            circuit["id"],
            "enabled":
            circuit["enabled"],
            "name":
            circuit["name"],
            "low_mode":
            low_mode_assignments[circuit_id],
            "summer_mode":
            summer_mode_assignments[circuit_id],
            "circuit_schedules":
            bmr.getCircuitSchedules(circuit_id),
        })

    # Schedules
    for schedule_id in range(len(bmr.getSchedules())):
        schedule = bmr.getSchedule(schedule_id)
        config_data["schedules"].append(schedule)

    # Low mode
    config_data["low_mode"] = bmr.getLowMode()

    # Summer mode
    config_data["summer_mode"] = bmr.getSummerMode()

    # Print YAML to stdout
    yaml = YAML()
    yaml.indent(mapping=2, sequence=4, offset=2)
    yaml.dump(config_data, sys.stdout)
示例#4
0
def setup_platform(hass, config, add_entities, discovery_info=None):
    import pybmr

    base_url = config.get(CONF_BASE_URL)
    user = config.get(CONF_USERNAME)
    password = config.get(CONF_PASSWORD)

    bmr = pybmr.Bmr(base_url, user, password)
    entities = [
        BmrRoomClimate(
            bmr=bmr,
            config=circuit_config,
            away_temperature=config.get(CONF_AWAY_TEMPERATURE, TEMP_MIN),
            can_cool=config.get(CONF_CAN_COOL, False),
            min_temperature=config.get(CONF_MIN_TEMPERATURE),
            max_temperature=config.get(CONF_MAX_TEMPERATURE),
        ) for circuit_config in config.get(CONF_CIRCUITS)
    ]
    add_entities(entities)
示例#5
0
def handle_load(args):
    # Connect to BMR HC64 controller
    bmr = pybmr.Bmr(*parse_url(args["url"]))

    # Parse YAML from stdin
    yaml = YAML()
    yaml.indent(mapping=2, sequence=4, offset=2)
    config_data = yaml.load(args["file"])

    # TODO: Sanity check of all input data

    # Low mode assignments
    low_mode_assignments_on = [
        circuit['id'] for circuit in config_data["circuits"]
        if circuit['low_mode']
    ]
    low_mode_assignments_off = [
        circuit['id'] for circuit in config_data["circuits"]
        if not circuit['low_mode']
    ]
    if args['verbose']:
        print("low_mode_assignments_on:", low_mode_assignments_on)
        print("low_mode_assignments_off:", low_mode_assignments_off)
    if not args["dry_run"]:
        bmr.setLowModeAssignments(low_mode_assignments_on, True)
        bmr.setLowModeAssignments(low_mode_assignments_off, False)

    # Summer mode assignments
    summer_mode_assignments_on = [
        circuit['id'] for circuit in config_data["circuits"]
        if circuit['summer_mode']
    ]
    summer_mode_assignments_off = [
        circuit['id'] for circuit in config_data["circuits"]
        if not circuit['summer_mode']
    ]
    if args['verbose']:
        print("summer_mode_assignments_on:", summer_mode_assignments_on)
        print("summer_mode_assignments_off:", summer_mode_assignments_off)
    if not args["dry_run"]:
        bmr.setSummerModeAssignments(summer_mode_assignments_on, True)
        bmr.setSummerModeAssignments(summer_mode_assignments_off, False)

    # Circuit schedule assignments
    for circuit in config_data["circuits"]:
        circuit_schedules = circuit["circuit_schedules"]
        if args['verbose']:
            print(
                "schedule assignment:",
                circuit["id"],
                circuit_schedules["day_schedules"],
                circuit_schedules["starting_day"],
            )
        if not args["dry_run"]:
            bmr.setCircuitSchedules(circuit["id"],
                                    circuit_schedules["day_schedules"],
                                    circuit_schedules["starting_day"])

    # Schedules
    for schedule in config_data["schedules"]:
        if args['verbose']:
            print("schedule:", schedule["id"], schedule["name"],
                  schedule["timetable"])
        if not args["dry_run"]:
            if schedule['timetable'] is not None:
                bmr.setSchedule(schedule["id"], schedule["name"],
                                schedule["timetable"])
            else:
                bmr.deleteSchedule(schedule['id'])

    # Low mode
    if args['verbose']:
        print("low_mode:", config_data["low_mode"]["enabled"],
              config_data["low_mode"]["temperature"])
    if not args["dry_run"]:
        bmr.setLowMode(config_data["low_mode"]["enabled"],
                       config_data["low_mode"]["temperature"])

    # Summer mode
    if args['verbose']:
        print("summer_mode:", config_data["summer_mode"])
    if not args["dry_run"]:
        bmr.setSummerMode(config_data["summer_mode"])