Beispiel #1
0
def test_convert_raw_status(mocker):
    mocker.patch('paradox.lib.ps')
    p = Paradox()
    status = convert_raw_status(message_parser_output)

    assert status["zone"] == {
        1: dict(open=False, tamper=False, low_battery=False, generated_alarm=False, presently_in_alarm=False,
                activated_entry_delay=False,
                activated_intellizone_delay=False, bypassed=False, shutted_down=False,
                tx_delay=False, supervision_trouble=False),
        2: dict(open=False, tamper=False, low_battery=False, generated_alarm=False,
                presently_in_alarm=False,
                activated_entry_delay=False,
                activated_intellizone_delay=False,
                bypassed=False,
                shutted_down=False,
                tx_delay=False,
                supervision_trouble=False)
    }

    assert status["partition"] == message_parser_output["partition_status"]
    assert status["door"] == {1: dict(open=False), 2: dict(open=False)}
    assert status["bus-module"] == {1: dict(trouble=False), 2: dict(trouble=False)}
    assert status["system"]["troubles"] == message_parser_output["system"]["troubles"]

    a = json.dumps(converted_status, sort_keys=True, indent=2, default=str)
    b = json.dumps(status, sort_keys=True, indent=2, default=str)
    assert a == b
Beispiel #2
0
def test_convert_raw_status(mocker):
    mocker.patch.object(ps, 'sendChange')
    mocker.patch.object(ps, 'sendEvent')
    connection = mocker.stub(name='Connection_stub')
    p = Paradox(connection)
    status = convert_raw_status(evo_status)

    assert status["zone"] == {
        1:
        dict(open=False,
             tamper=False,
             low_battery=False,
             generated_alarm=False,
             presently_in_alarm=False,
             activated_entry_delay=False,
             activated_intellizone_delay=False,
             bypassed=False,
             shutted_down=False,
             tx_delay=False,
             supervision_trouble=False),
        2:
        dict(open=False,
             tamper=False,
             low_battery=False,
             generated_alarm=False,
             presently_in_alarm=False,
             activated_entry_delay=False,
             activated_intellizone_delay=False,
             bypassed=False,
             shutted_down=False,
             tx_delay=False,
             supervision_trouble=False)
    }
    assert status["partition"] == evo_status["partition_status"]
    assert status["door"] == {1: dict(open=False), 2: dict(open=False)}
    assert status["bus-module"] == {
        1: dict(trouble=False),
        2: dict(trouble=False)
    }
    assert status["system"]["power"] == {
        "vdc": 16.5,
        "battery": 13.4,
        "dc": 13.5
    }
    assert status["system"]["date"] == {
        'time': datetime.datetime(2019, 10, 11, 21, 12, 2),
        'weekday': 6
    }
    assert status["system"]["troubles"] == evo_status["system"]["troubles"]
Beispiel #3
0
    def _process_status(raw_status: Container) -> None:
        status = convert_raw_status(raw_status)

        for limit_key, limit_arr in cfg.LIMITS.items():
            if limit_key not in status:
                continue

            status[limit_key].filter(limit_arr)

        #     # TODO: throttle power update messages
        #     if time.time() - self.last_power_update >= cfg.POWER_UPDATE_INTERVAL:
        #         force = PublishPropertyChange.YES if cfg.PUSH_POWER_UPDATE_WITHOUT_CHANGE else PublishPropertyChange.NO

        if cfg.LOGGING_DUMP_STATUS:
            logger.debug("properties: %s", status)

        ps.sendMessage('status_update', status=status)