Example #1
0
        protected override async Task <ThingState> OnInitAsync()
        {
            var port = _gatewaySetupInfo.GatewayType == "HmIp"
                ? CcuRpcPorts.HomeMaticIp
                : CcuRpcPorts.HomeMatic;

            _xmlRpcApi = HomeMaticXmlRpcApiBuilder.Create()
                         .ForUrl($"{_gatewaySetupInfo.Address}:{port}")
                         .Build();

            _connection = new CcuConnection(_xmlRpcApi);

            var xmlRpcServer = new XmlRpcServer(new AspNetCoreHttpServer(), new XmlRpcServerMethods(),
                                                Encoding.GetEncoding("iso-8859-1"));

            xmlRpcServer.Urls.Add("http://homie-workstation:12345/");

            _eventServer = new CcuXmlRpcEventServer(xmlRpcServer);

            _eventServer.RegisterEventHandler(new HomeMaticGatewayEventHandler(_mediator, $"GW_{_gatewaySetupInfo.Id.Gateway}"));

            await _eventServer.StartAsync();

            await _xmlRpcApi.InitAsync("http://homie-workstation:12345/", $"GW_{_gatewaySetupInfo.Id.Gateway}");

            return(ThingState.Online);
        }
 public HomeMaticThingChannelHandler(ThingId thingId, string name, string channelAddress, string valueKey,
                                     IHomeMaticXmlRpcApi xmlRpcApi, IMediator mediator) : base(thingId, name)
 {
     _channelAddress = channelAddress;
     _valueKey       = valueKey;
     _mediator       = mediator;
     _ccuValue       = new CcuValueIo(xmlRpcApi, channelAddress, valueKey);
 }
 public HomeMaticThingHandler(IThingSetupInfo thingSetupInfo, ICcuConnection ccuConnection,
                              IHomeMaticXmlRpcApi xmlRpcApi, IMediator mediator)
 {
     _thingSetupInfo = thingSetupInfo;
     _ccuConnection  = ccuConnection;
     _xmlRpcApi      = xmlRpcApi;
     _mediator       = mediator;
 }
Example #4
0
        public CcuValueIo(IHomeMaticXmlRpcApi homeMaticXmlRpcApi, CcuValueAddress valueAddress)
        {
            Ensure.IsNotNull(homeMaticXmlRpcApi, nameof(homeMaticXmlRpcApi));
            Ensure.IsNotNull(valueAddress, nameof(valueAddress));

            _homeMaticXmlRpcApi = homeMaticXmlRpcApi;
            ValueAddress        = valueAddress;
        }
Example #5
0
        private async Task LoadParameterDescriptions(IHomeMaticXmlRpcApi homeMaticXmlRpcApi)
        {
            Console.WriteLine("Press key to continue...");
            Console.ReadKey();
            Console.WriteLine("Starting xml rpc server...");

            var httpServer = new AspNetCoreHttpServer
            {
                DisableLogging     = false,
                AllowSynchronousIO = true
            };

            var xmlRpcServer = new XmlRpcServer(httpServer)
            {
                Encoding = Encoding.GetEncoding("iso-8859-1")
            };

            xmlRpcServer.Urls.Add(XmlRpcUrl);

            var ccuXmlRpcServer =
                new CcuXmlRpcEventServer(xmlRpcServer);

            //var eventReceiver = new CcuEventReceiver();
            //eventReceiver.EventMessageTopic
            //    .Register<HomeMaticEventMessage>()
            //    .SubscribeOn(new TaskPoolScheduler(new TaskFactory()))
            //    .Subscribe(msg => Console.WriteLine($"{msg.Address}.{msg.ValueKey} = {msg.Value}"));

            StartServer(ccuXmlRpcServer, homeMaticXmlRpcApi);

            Console.ReadKey();

            await homeMaticXmlRpcApi.InitAsync("", "TestIntf");

            await ccuXmlRpcServer.StopAsync();
        }
Example #6
0
 public CcuDevice(ICcuDeviceInfo deviceInfo, IHomeMaticXmlRpcApi xmlRpcApi) : base(deviceInfo, xmlRpcApi)
 {
     _channels = new List <ICcuDeviceChannel>();
 }
Example #7
0
 protected CcuDeviceBase(ICcuDeviceInfo deviceInfo, IHomeMaticXmlRpcApi xmlRpcApi)
 {
     DeviceInfo = deviceInfo;
     XmlRpcApi  = xmlRpcApi;
 }
Example #8
0
        private void StartServer(CcuXmlRpcEventServer ccuXmlRpcServer, IHomeMaticXmlRpcApi homeMaticXmlRpcApi)
        {
            Task.Run(ccuXmlRpcServer.StartAsync);

            homeMaticXmlRpcApi.InitAsync(XmlRpcUrl, "TestIntf");
        }
Example #9
0
 public CcuValueIo(IHomeMaticXmlRpcApi homeMaticXmlRpcApi, string deviceAddress, string valueKey) :
     this(homeMaticXmlRpcApi, new CcuValueAddress(deviceAddress, valueKey))
 {
 }
Example #10
0
        public CcuConnection(IHomeMaticXmlRpcApi xmlRpcApi)
        {
            Ensure.IsNotNull(xmlRpcApi, nameof(xmlRpcApi));

            XmlRpcApi = xmlRpcApi;
        }
Example #11
0
 public CcuDeviceChannel(ICcuDevice parent, ICcuDeviceInfo channelInfo, IHomeMaticXmlRpcApi xmlRpcApi) : base(channelInfo, xmlRpcApi)
 {
     Parent = parent;
 }