c-soft / satel_integra

MIT License
24 stars 24 forks source link

Satel Integra arming one zone (partition) only #6

Open grubymisiek opened 5 years ago

grubymisiek commented 5 years ago

There is a mistake in Satel's documentation which probably implements mistakes in this script. There is often mistaken term partition with zone together with input. To understand it we have to know roughly an idea of Satel's architecture. The partition is user oriented and user unique, one can not have access to more than one partition. The zone is tied to parition only theoretically, to have a kind of hierarchy (especially when working with DLOADX). Every zone, partition, input have its own numbering, independent. So, to the point. Every time we talk about zones regarding this script we really talk about inputs. Every time we talk about partitions - these are zones. Actually we do not need to know which partition or zone an input is tied to as we only check its state. The same sitiuation rules arming. That is the user who is tied to a partition and can arm/disarm only that zones/inputs which are inside it. So it is not true your script operates on one partition only.

So what we need to fix is to be able to arm/disarm more than one zone. When we send arm command (x80) the default behavior in mode=0 is to arm all zones and inputs inside it. But we have to point which zones there really are. This is the command we send now: \xfe\xfe\x80\x**\x**\x**\x**\xff\xff\xff\xff\x01\x00\x00\x00\x5f\xff\xfe\x0d where x80 is the arm command in mode 0, x** [...] xff password (max 16 digits, no coding, decimal value, ff means unused), and the part \x01\x00\x00\x00 stands for the zones we have to arm/disarm This one points exactly to the first one. int.from_bytes(b'\x01\x00\x00\x00', byteorder='little') equals 1 So correcting the Satel's manual - we talk here about zones not partitions. The key for choosing the zones is as follows: 4 bytes partition list:

So setting partition = 15 actually does the job for me ;).

    @property
    def _partition_bytes(self):
        partition = 1 << self._partition_id - 1
        return (15).to_bytes(4, 'little')

It might be a good idea to arm all zones by default, I have to check if that always works.

c-soft commented 5 years ago

Thanks for extensive write up. Indeed, I'm following names in the API description document, hence some folks get confused, including myself at the beginning :)

To be clear, in Polish:

I also agree that best approach would be to arm/disarm all of the partitions (or "strefy" in PL) , but not sure if it's easily doable. For now, your workaround seems quite legit :)

I'm thinking about adding support for multiple partitions, but that's another story. I thought about adding multiple panels, each panel could represent one or many partitions. That would give the most flexibility to folks.

ghost commented 5 years ago

Hi Support for more STREFA is need. In some STREFA i use PIR but in some i use only contactron. Sometimes i need ARM only PI but sometimes i need ARM all.