Exemplo n.º 1
0
        public async Task Run()
        {
            _container = CreateDiContainer();

            var apiBuilder = _container.GetInstance <IXmlRpcProxyBuilder <IHomeMaticXmlRpcApi> >();

            var xmlRpcApiHmIp = apiBuilder
                                .ForUrl("http://homematic-ccu2:" + CcuRpcPorts.HomeMaticIp)
                                .Build();

            var xmlRpcApi = apiBuilder
                            .ForUrl("http://homematic-ccu2:" + CcuRpcPorts.HomeMatic)
                            .Build();

            var connection = new CcuConnection(xmlRpcApiHmIp);

            var deviceInfos = await connection.GetDeviceInfosAsync();

            var devices = await connection.GetDevicesAsync();

            var temperature = await xmlRpcApi.GetValueAsync <double>("NEQ1142873:1", "TEMPERATURE");

            Console.WriteLine($"Temperature: {temperature}");

            var deviceDescriptions = await xmlRpcApiHmIp.ListDevicesAsync();

            deviceDescriptions.ForEach(x => Console.WriteLine($"{x.Address}"));

            Console.WriteLine();

            await LoadParameterDescriptions(xmlRpcApiHmIp);
        }
Exemplo n.º 2
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);
        }