Nodes

The Node Manager is a central component that manages all the nodes in your hydroponic system.

Nodes are individual components that perform specific tasks within the hydroponic system. They can have sensors, actuators, or controllers.

All applications need a NodeManager

Example:

import asyncio

from openhydroponics.node_manager import NodeManager


async def main():
    nm = NodeManager()
    await asyncio.sleep(10)

if __name__ == "__main__":
    try:
        asyncio.run(main())
    except KeyboardInterrupt:
        pass

Getting a reference to a node object use the function NodeManager.get_node() or NodeManager.request_node().

Endpoints

All nodes have one or several endpoints. A node that supports temperature and humidity may have two endpoints, one for each sensor. If a node supports multiple variants of the same type of sensor or actuators each individual sensor/actuator will have its own endpoint. Example: A node with 3 pump outlets will have three endpoints, one for each pump.

API reference

class Node(node_id: int, uuid: UUID, manager: NodeManager, phy_iface: CanPhyIface)
get_endpoint(endpoint_id: int) Endpoint | None
get_endpoint_value(endpoint_id: int) Tuple[float, int]
handle_sensor_reading(msg: SensorReading)
async interview()
property node_id: int
async send_and_wait(request: Any)
send_msg(msg: Any)
send_rtr(msg: Any)
async set_config(config_no: int, config)
property uuid: UUID
async wait_for(msg: Any)
class NodeManager(phy_iface: CanPhyIface = None)
get_node(uuid: str | UUID) Node | None
property node_id: int
async on_message_received(msg: Message)
async request_node(uuid: str | UUID, timeout_s: float = 2.0) Node | None