import pika import time def publish_events(): connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost')) channel = connection.channel() channel.exchange_declare(exchange='greenhouse_events', exchange_type='fanout') events = [ "Влажность превысила верхнюю границу", "Влажность упала за нижнюю границу", "Полив начат", "Полив остановлен" ] while True: event = events[int(time.time()) % len(events)] channel.basic_publish(exchange='greenhouse_events', routing_key='', body=event) print(f'Отправлено: {event}') time.sleep(1) if __name__ == "__main__": publish_events()