<commit_before>﻿using System.Text;
using ParadoxIp;
using ParadoxIp.Enum;
using ParadoxIp.Model;
using ServiceStack.Logging;
using uPLibrary.Networking.M2Mqtt;

namespace Paradox.MQTT
{
    public class MqttCallbacks : IParadoxEventCallbacks
    {
        private readonly ILog logger = LogManager.GetLogger(typeof(MqttCallbacks));
        private readonly ParadoxMqttSettings settings;
        private readonly MqttClient client;
        public MqttCallbacks(ParadoxMqttSettings settings)
        {
            this.settings = settings;
            client = new MqttClient(settings.BrokerUrl);
        }

        public void PutDeviceUpdate(Device device)
        {
            if (device.Status == DeviceStatus.Unknown)
                return;

            string topic = string.Format("{0}/zone/{1}/state",settings.RootTopic, device.ZoneId);
            client.Connect(settings.ClientId);
            client.Publish(topic, Encoding.UTF8.GetBytes(device.Status.ToString()), settings.QosLevel, settings.Retain);
            logger.DebugFormat("{0}[{1}]",topic, device.Status);
        }

        public void PutPartitionUpdate(Partition partition)
        {
            if (partition.Status == PartitionStatus.Unknown)
                return;

            string topic = string.Format("{0}/partition/{1}/state",settings.RootTopic, (int)partition.Id);
            client.Connect(settings.ClientId);
            client.Publish(topic, Encoding.UTF8.GetBytes(partition.Status.ToString()), settings.QosLevel, settings.Retain);
            logger.DebugFormat("{0}[{1}]",topic, partition.Status);
        }
    }

}<commit_msg>small fix to publish mqtt topic<commit_after>﻿using System.Text;
using ParadoxIp;
using ParadoxIp.Enum;
using ParadoxIp.Model;
using ServiceStack.Logging;
using uPLibrary.Networking.M2Mqtt;

namespace Paradox.MQTT
{
    public class MqttCallbacks : IParadoxEventCallbacks
    {
        private readonly ILog logger = LogManager.GetLogger(typeof(MqttCallbacks));
        private readonly ParadoxMqttSettings settings;
        private readonly MqttClient client;
        public MqttCallbacks(ParadoxMqttSettings settings)
        {
            this.settings = settings;
            client = new MqttClient(settings.BrokerUrl);
        }

        public void PutDeviceUpdate(Device device)
        {
            if (device.Status == DeviceStatus.Unknown)
                return;

            string topic = string.Format("{0}/zone/{1}/state",settings.RootTopic, device.ZoneId);
            client.Connect(settings.ClientId);
            client.Publish(topic, Encoding.UTF8.GetBytes(device.Status.ToString()), settings.QosLevel, settings.Retain);
            logger.DebugFormat("{0}[{1}]",topic, device.Status);
        }

        public void PutPartitionUpdate(Partition partition)
        {
            if (partition.Status == PartitionStatus.Unknown)
                return;

            string topic = string.Format("{0}/partition/{1}/status",settings.RootTopic, (int)partition.Id);
            client.Connect(settings.ClientId);
            client.Publish(topic, Encoding.UTF8.GetBytes(partition.Status.ToString()), settings.QosLevel, settings.Retain);
            logger.DebugFormat("{0}[{1}]",topic, partition.Status);
        }
    }

}
{'fraction_non_alphanumeric': 0.10855565777368906, 'fraction_numerical': 0.006746396810794235, 'mean_word_length': 2.749425287356322, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4012942', 'n_tokens_mistral': 914, 'n_tokens_neox': 898, 'n_words': 159}