BAC0.core.functions package
Submodules
Note on DeviceCommunicationControl
DeviceCommunicationControl is not part of BAC0.core.functions in this version.
If you’re looking for device-level commands, see BAC0.core.functions.Reinitialize.
BAC0.core.functions.Discover module
- class BAC0.core.functions.Discover.Discover[source]
Bases:
objectMain function to explore the network and find devices.
- clear_notes()
Clear notes object
- discover(networks: str | List[int] | int = 'known', limits: Tuple[int, int] = (0, 4194303), global_broadcast: bool = False, reset: bool = False) None[source]
- property known_network_numbers: Set[int]
- log(note, *, level: str | int = 10)
Add a log entry…no note
- log_subtitle(subtitle, args=None, width=35)
- log_title(title, args=None, width=35)
- logname = 'BAC0.core.functions.Discover | Discover'
- note(note, *, level=20, log=True)
Add note to the object. By default, the note will also be logged :param note: (str) The note itself :param level: (logging.level) :param log: (boolean) Enable or disable logging of note
- property notes
Retrieve notes list as a Pandas Series
BAC0.core.functions.CoV module
BAC0.core.functions.GetIPAddr module
Utility function to retrieve a functionnal IP and a correct broadcast IP address. Goal : not use 255.255.255.255 as a broadcast IP address as it is not accepted by every devices (>3.8.38.1 bacnet.jar of Tridium Jace for example)
- class BAC0.core.functions.GetIPAddr.HostIP(port: int | None = None)[source]
Bases:
objectSpecial class to identify host IP informations
- property address: Address
IP Address using bacpypes Address format
- clear_notes()
Clear notes object
- property ip_address
IP Address/subnet
- property ip_address_subnet
IP Address/subnet
- log(note, *, level: str | int = 10)
Add a log entry…no note
- log_subtitle(subtitle, args=None, width=35)
- log_title(title, args=None, width=35)
- logname = 'BAC0.core.functions.GetIPAddr | HostIP'
- property mask
Subnet mask
- note(note, *, level=20, log=True)
Add note to the object. By default, the note will also be logged :param note: (str) The note itself :param level: (logging.level) :param log: (boolean) Enable or disable logging of note
- property notes
Retrieve notes list as a Pandas Series
- property port
IP Port used
BAC0.core.functions.Alias module
- class BAC0.core.functions.Alias.Alias[source]
Bases:
objectBacpypes3 now offer a wide range a functions out of the box This mixin bring them to the BAC0 app so it’s easy to use
- clear_notes()
Clear notes object
- iam(address=None)[source]
Build an IAm response. IAm are sent in response to a WhoIs request that; matches our device ID, whose device range includes us, or is a broadcast. Content is defined by the script (deviceId, vendor, etc…)
Example:
iam()
- async init_routing_table(address=None)[source]
irt <addr>
Send an empty Initialize-Routing-Table message to an address, a router will return an acknowledgement with its routing table configuration.
- log(note, *, level: str | int = 10)
Add a log entry…no note
- log_subtitle(subtitle, args=None, width=35)
- log_title(title, args=None, width=35)
- logname = 'BAC0.core.functions.Alias | Alias'
- note(note, *, level=20, log=True)
Add note to the object. By default, the note will also be logged :param note: (str) The note itself :param level: (logging.level) :param log: (boolean) Enable or disable logging of note
- property notes
Retrieve notes list as a Pandas Series
- async use_router(router_infos: Tuple[Address | str, int | List[int]] | Tuple[Address | str, int | List[int], int | None] = (None, [], None))[source]
- async what_is_network_number(destination=None, timeout=3)[source]
winn [ <addr> ]
Send a What-Is-Network-Number message. If the address is unspecified the message is locally broadcast.
- async who_is(address=None, low_limit=0, high_limit=4194303, timeout=3)[source]
Build a WhoIs request. WhoIs requests are sent to discover devices on the network. If an address is specified, the request is sent to that address. Otherwise, the request is broadcast to the local network.
- Parameters:
address – (optional) The address to send the request to.
destination – (optional) The destination address.
- Returns:
List of IAm responses.
Example:
import BAC0 bacnet = BAC0.lite() bacnet.whois() bacnet.whois('2:5')
- async whohas(object_id=None, object_name=None, low_limit=0, high_limit=4194303, destination=None, timeout=5)[source]
Build a WhoHas request.
- Parameters:
object_id – (optional) The address to send the request to, if unused object_name must be present.
object_name – (optional) The address to send the request to, if unused object_id must be present.
destination – (optional) The destination address, if empty local broadcast will be used.
timeout – (optional) The timeout for the WhoHas.
- Returns:
IAm response.
Example:
import BAC0 bacnet = BAC0.lite() bacnet.whohas(object_name='SomeDevice')
- async whois_router_to_network(network=None, *, destination=None, timeout=3, global_broadcast=False)[source]
Send a Who-Is-Router-To-Network request. This request is used to discover routers on the network that can route messages to a specific network.
The function sends a broadcast message to the local network to find routers that can route messages to the specified network. The response will contain information about the routers that can handle the routing.
Example:
whois_router_to_network()
BAC0.core.functions.Reinitialize module
Reinitialize.py - creation of ReinitializeDeviceRequest
- class BAC0.core.functions.Reinitialize.Reinitialize[source]
Bases:
objectMixin to support Reinitialize from BAC0 to other devices
- clear_notes()
Clear notes object
- log(note, *, level: str | int = 10)
Add a log entry…no note
- log_subtitle(subtitle, args=None, width=35)
- log_title(title, args=None, width=35)
- logname = 'BAC0.core.functions.Reinitialize | Reinitialize'
- note(note, *, level=20, log=True)
Add note to the object. By default, the note will also be logged :param note: (str) The note itself :param level: (logging.level) :param log: (boolean) Enable or disable logging of note
- property notes
Retrieve notes list as a Pandas Series
BAC0.core.functions.TimeSync module
TimeSync.py - creation of time synch requests
- class BAC0.core.functions.TimeSync.TimeHandler(tz: str = 'America/Montreal')[source]
Bases:
objectThis class will deal with Time / Timezone related features To deal with DateTime Value correctly we need to be aware of timezone.
- property now: datetime
- class BAC0.core.functions.TimeSync.TimeSync[source]
Bases:
objectMixin to support Time Synchronisation from BAC0 to other devices
- clear_notes()
Clear notes object
- log(note, *, level: str | int = 10)
Add a log entry…no note
- log_subtitle(subtitle, args=None, width=35)
- log_title(title, args=None, width=35)
- logname = 'BAC0.core.functions.TimeSync | TimeSync'
- note(note, *, level=20, log=True)
Add note to the object. By default, the note will also be logged :param note: (str) The note itself :param level: (logging.level) :param log: (boolean) Enable or disable logging of note
- property notes
Retrieve notes list as a Pandas Series
- time_sync(destination: str | None = None, datetime: DateTime | None = None, UTC: bool = False) None[source]
Take local time and send it to devices. User can also provide a datetime value (constructed following bacpypes.basetypes.Datetime format).
To create a DateTime
from bacpypes.basetypes import DateTime from bacpypes.primitivedata import Date, Time # Create date and time _date = Date('2019-08-05') _time = Time('16:45') # Create Datetime _datetime = DateTime(date=_date.value, time=_time.value) # Pass this to the function bacnet.time_sync(datetime=_datetime)
BAC0.core.functions.Schedule module
- class BAC0.core.functions.Schedule.Schedule[source]
Bases:
objectEverything you need to write to a schedule
- WeeklySchedule
alias of
ArrayOfDailySchedule
- clear_notes()
Clear notes object
- create_weeklySchedule(dict_schedule, object_reference=None)[source]
From a structured dict (see schedule_example), create a WeeklySchedule an ArrayOf(DailySchedule)
- days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
- log(note, *, level: str | int = 10)
Add a log entry…no note
- log_subtitle(subtitle, args=None, width=35)
- log_title(title, args=None, width=35)
- logname = 'BAC0.core.functions.Schedule | Schedule'
- note(note, *, level=20, log=True)
Add note to the object. By default, the note will also be logged :param note: (str) The note itself :param level: (logging.level) :param log: (boolean) Enable or disable logging of note
- property notes
Retrieve notes list as a Pandas Series
- async read_weeklySchedule(address, schedule_instance)[source]
This function will turn the weeklySchedule received into a human readable dict. This dict can then be modified and used to write back to controller using bacnet.write_weeklySchedule
- schedule_example_analog = {'states': 'analog', 'week': {'friday': [('5:00', 22), ('18:00', 19)], 'monday': [('1:00', 22), ('18:00', 19)], 'saturday': [('6:00', 22), ('18:00', 19)], 'sunday': [('7:00', 22), ('18:00', 19)], 'thursday': [('4:00', 22), ('18:00', 19)], 'tuesday': [('2:00', 22), ('18:00', 19)], 'wednesday': [('3:00', 22), ('18:00', 19)]}}
- schedule_example_binary = {'states': {'active': 1, 'inactive': 0}, 'week': {'friday': [('5:00', 'active'), ('16:00', 'inactive')], 'monday': [('1:00', 'active'), ('16:00', 'inactive')], 'saturday': [('6:00', 'active'), ('16:00', 'inactive')], 'sunday': [('7:00', 'active'), ('16:00', 'inactive')], 'thursday': [('4:00', 'active'), ('16:00', 'inactive')], 'tuesday': [('2:00', 'active'), ('16:00', 'inactive')], 'wednesday': [('3:00', 'active'), ('16:00', 'inactive')]}}
- schedule_example_multistate = {'states': {'Not Set': 4, 'Occupied': 1, 'Standby': 3, 'UnOccupied': 2}, 'week': {'friday': [('5:00', 'Occupied'), ('17:00', 'UnOccupied')], 'monday': [('1:00', 'Occupied'), ('17:00', 'UnOccupied')], 'saturday': [('6:00', 'Occupied'), ('17:00', 'UnOccupied')], 'sunday': [('7:00', 'Occupied'), ('17:00', 'UnOccupied')], 'thursday': [('4:00', 'Occupied'), ('17:00', 'UnOccupied')], 'tuesday': [('2:00', 'Occupied'), ('17:00', 'UnOccupied')], 'wednesday': [('3:00', 'Occupied'), ('17:00', 'UnOccupied')]}}
- schedules = {}
BAC0.core.functions.Calendar module
- class BAC0.core.functions.Calendar.Calendar[source]
Bases:
objectEverything you need to write dates and date ranges to a calendar object.
- DateList
alias of
ArrayOfCalendarEntry
- clear_notes()
Clear notes object
- create_calendar(dict_calendar)[source]
From a structured dict (see dateList_example), create a DateList an ArrayOf(CalendarEntry)
- datelist_example = {'dateRanges': [{'endDate': '2021/3/21', 'startDate': '2021/3/16'}, {'endDate': '2021/3/7', 'startDate': '2021/3/5'}], 'dates': [{'date': '2021/3/14', 'recurring': False}, {'date': '2021/3/10', 'recurring': True}]}
- log(note, *, level: str | int = 10)
Add a log entry…no note
- log_subtitle(subtitle, args=None, width=35)
- log_title(title, args=None, width=35)
- logname = 'BAC0.core.functions.Calendar | Calendar'
- note(note, *, level=20, log=True)
Add note to the object. By default, the note will also be logged :param note: (str) The note itself :param level: (logging.level) :param log: (boolean) Enable or disable logging of note
- property notes
Retrieve notes list as a Pandas Series
BAC0.core.functions.Text module
- class BAC0.core.functions.Text.TextMixin[source]
Bases:
objectMixin with functions to deal with text properties. Adding features to “network” itself.
- build_text_write_request(addr: str, obj_type: str, obj_inst: int, value: str, prop_id: str = 'description') WritePropertyRequest[source]