mirror of
https://bitbucket.org/myhomie/mycorerepository.git
synced 2025-12-06 09:41:19 +00:00
MC Add Zigbee2Mqtt device handle (+ Aqara Device, Aqara Cube, Aqara Switch) + arlo API postman collection + network monitor script
This commit is contained in:
parent
d770dd71f3
commit
bac245a138
210
MyCore/Arlo API.postman_collection.json
Normal file
210
MyCore/Arlo API.postman_collection.json
Normal file
@ -0,0 +1,210 @@
|
|||||||
|
{
|
||||||
|
"variables": [],
|
||||||
|
"info": {
|
||||||
|
"name": "Arlo API",
|
||||||
|
"_postman_id": "665ada25-ab68-51d0-aa6e-ab376ded9d8a",
|
||||||
|
"description": "",
|
||||||
|
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
|
||||||
|
},
|
||||||
|
"item": [
|
||||||
|
{
|
||||||
|
"name": "Login Arlo",
|
||||||
|
"request": {
|
||||||
|
"url": "https://arlo.netgear.com/hmsweb/login/v2",
|
||||||
|
"method": "POST",
|
||||||
|
"header": [
|
||||||
|
{
|
||||||
|
"key": "Content-Type",
|
||||||
|
"value": "application/json",
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"body": {
|
||||||
|
"mode": "raw",
|
||||||
|
"raw": "{\"email\":\"fransolet.thomas@gmail.com\",\"password\":\"Coconuts09\"}"
|
||||||
|
},
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "User Profile",
|
||||||
|
"request": {
|
||||||
|
"url": "https://arlo.netgear.com/hmsweb/users/profile",
|
||||||
|
"method": "GET",
|
||||||
|
"header": [
|
||||||
|
{
|
||||||
|
"key": "Authorization",
|
||||||
|
"value": "2_5MS700UkeZA_mvcLkTG2MEmHR-mEKNG2M4MmPIaYKMmJa2c-TlCs4kTaCr0i6gXha10UY7HVl_RBmG71Ub4_wYSyT2kawx1KKMkCsSxp_9E4H0oLNsNrMUhgfB2n6pem6xS39Y5fHCc1gT_IpzBfP7MbQPRgrVeh177DHdvUd47Z",
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"body": {},
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "User Session",
|
||||||
|
"request": {
|
||||||
|
"url": "https://arlo.netgear.com/hmsweb/users/session",
|
||||||
|
"method": "GET",
|
||||||
|
"header": [
|
||||||
|
{
|
||||||
|
"key": "Authorization",
|
||||||
|
"value": "2_5MS700UkeZA_mvcLkTG2MEmHR-mEKNG2M4MmPIaYKMmJa2c-TlCs4kTaCr0i6gXha10UY7HVl_RBmG71Ub4_wYSyT2kawx1KKMkCsSxp_9E4H0oLNsNrMUhgfB2n6pem6xS39Y5fHCc1gT_IpzBfP7MbQPRgrVeh177DHdvUd47Z",
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"body": {},
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "User Friends",
|
||||||
|
"request": {
|
||||||
|
"url": "https://arlo.netgear.com/hmsweb/users/friends",
|
||||||
|
"method": "GET",
|
||||||
|
"header": [
|
||||||
|
{
|
||||||
|
"key": "Authorization",
|
||||||
|
"value": "2_5MS700UkeZA_mvcLkTG2MEmHR-mEKNG2M4MmPIaYKMmJa2c-TlCs4kTaCr0i6gXha10UY7HVl_RBmG71Ub4_wYSyT2kawx1KKMkCsSxp_9E4H0oLNsNrMUhgfB2n6pem6xS39Y5fHCc1gT_IpzBfP7MbQPRgrVeh177DHdvUd47Z",
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"body": {},
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "User Location",
|
||||||
|
"request": {
|
||||||
|
"url": "https://arlo.netgear.com/hmsweb/users/locations",
|
||||||
|
"method": "GET",
|
||||||
|
"header": [
|
||||||
|
{
|
||||||
|
"key": "Authorization",
|
||||||
|
"value": "2_5MS700UkeZA_mvcLkTG2MEmHR-mEKNG2M4MmPIaYKMmJa2c-TlCs4kTaCr0i6gXha10UY7HVl_RBmG71Ub4_wYSyT2kawx1KKMkCsSxp_9E4H0oLNsNrMUhgfB2n6pem6xS39Y5fHCc1gT_IpzBfP7MbQPRgrVeh177DHdvUd47Z",
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"body": {},
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "User Service Level",
|
||||||
|
"request": {
|
||||||
|
"url": "https://arlo.netgear.com/hmsweb/users/serviceLevel/v2",
|
||||||
|
"method": "GET",
|
||||||
|
"header": [
|
||||||
|
{
|
||||||
|
"key": "Authorization",
|
||||||
|
"value": "2_5MS700UkeZA_mvcLkTG2MEmHR-mEKNG2M4MmPIaYKMmJa2c-TlCs4kTaCr0i6gXha10UY7HVl_RBmG71Ub4_wYSyT2kawx1KKMkCsSxp_9E4H0oLNsNrMUhgfB2n6pem6xS39Y5fHCc1gT_IpzBfP7MbQPRgrVeh177DHdvUd47Z",
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"body": {},
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Get Devices",
|
||||||
|
"request": {
|
||||||
|
"url": "https://arlo.netgear.com/hmsweb/users/devices",
|
||||||
|
"method": "GET",
|
||||||
|
"header": [
|
||||||
|
{
|
||||||
|
"key": "Authorization",
|
||||||
|
"value": "2_5MS700UkeZA_mvcLkTG2MEmHR-mEKNG2M4MmPIaYKMmJa2c-TlCs4kTaCr0i6gXha10UY7HVl_RBmG71Ub4_wYSyT2kawx1KKMkCsSxp_9E4H0oLNsNrMUhgfB2n6pem6xS39Y5fHCc1gT_IpzBfP7MbQPRgrVeh177DHdvUd47Z",
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"body": {},
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Get Library",
|
||||||
|
"request": {
|
||||||
|
"url": "https://arlo.netgear.com/hmsweb/users/library",
|
||||||
|
"method": "POST",
|
||||||
|
"header": [
|
||||||
|
{
|
||||||
|
"key": "Authorization",
|
||||||
|
"value": "2_5MS700UkeZA_mvcLkTG2MEmHR-mEKNG2M4MmPIaYKMmJa2c-TlCs4kTaCr0i6gXha10UY7HVl_RBmG71Ub4_wYSyT2kawx1KKMkCsSxp_9E4H0oLNsNrMUhgfB2n6pem6xS39Y5fHCc1gT_IpzBfP7MbQPRgrVeh177DHdvUd47Z",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Content-Type",
|
||||||
|
"value": "application/json;charset=UTF-8",
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"body": {
|
||||||
|
"mode": "raw",
|
||||||
|
"raw": "{\"dateFrom\": \"20190126\",\"dateTo\": \"20200105\"}"
|
||||||
|
},
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Get Library Metadata",
|
||||||
|
"request": {
|
||||||
|
"url": "https://arlo.netgear.com/hmsweb/users/library/metadata/v2",
|
||||||
|
"method": "GET",
|
||||||
|
"header": [
|
||||||
|
{
|
||||||
|
"key": "Authorization",
|
||||||
|
"value": "2_5MS700UkeZA_mvcLkTG2MEmHR-mEKNG2M4MmPIaYKMmJa2c-TlCs4kTaCr0i6gXha10UY7HVl_RBmG71Ub4_wYSyT2kawx1KKMkCsSxp_9E4H0oLNsNrMUhgfB2n6pem6xS39Y5fHCc1gT_IpzBfP7MbQPRgrVeh177DHdvUd47Z",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "",
|
||||||
|
"value": "",
|
||||||
|
"description": "",
|
||||||
|
"disabled": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"body": {
|
||||||
|
"mode": "raw",
|
||||||
|
"raw": "{\"dateFrom\": \"20190126\",\"dateTo\": \"20200105\"}"
|
||||||
|
},
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Get Payment offers",
|
||||||
|
"request": {
|
||||||
|
"url": "https://arlo.netgear.com/hmsweb/users/payment/offers",
|
||||||
|
"method": "GET",
|
||||||
|
"header": [
|
||||||
|
{
|
||||||
|
"key": "Authorization",
|
||||||
|
"value": "2_5MS700UkeZA_mvcLkTG2MEmHR-mEKNG2M4MmPIaYKMmJa2c-TlCs4kTaCr0i6gXha10UY7HVl_RBmG71Ub4_wYSyT2kawx1KKMkCsSxp_9E4H0oLNsNrMUhgfB2n6pem6xS39Y5fHCc1gT_IpzBfP7MbQPRgrVeh177DHdvUd47Z",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "",
|
||||||
|
"value": "",
|
||||||
|
"description": "",
|
||||||
|
"disabled": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"body": {
|
||||||
|
"mode": "raw",
|
||||||
|
"raw": "{\"dateFrom\": \"20190126\",\"dateTo\": \"20200105\"}"
|
||||||
|
},
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
using MongoDB.Bson;
|
using MongoDB.Bson;
|
||||||
using MongoDB.Bson.Serialization.Attributes;
|
using MongoDB.Bson.Serialization.Attributes;
|
||||||
|
using MyCore.Models.Providers.Zigbee.Aqara;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -7,13 +8,10 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace MyCore.Models.Aqara
|
namespace MyCore.Models.Aqara
|
||||||
{
|
{
|
||||||
public class Cube
|
public class AqaraCube : AqaraDevice
|
||||||
{
|
{
|
||||||
public double Angle { get; set; }
|
public double Angle { get; set; }
|
||||||
public int LinkQuality { get; set; }
|
|
||||||
public int Side { get; set; }
|
public int Side { get; set; }
|
||||||
public int Battery { get; set; }
|
|
||||||
public int Voltage { get; set; }
|
|
||||||
public string Action { get; set; }
|
public string Action { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
14
MyCore/Models/Providers/Zigbee/Aqara/AqaraDevice.cs
Normal file
14
MyCore/Models/Providers/Zigbee/Aqara/AqaraDevice.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MyCore.Models.Providers.Zigbee.Aqara
|
||||||
|
{
|
||||||
|
public class AqaraDevice
|
||||||
|
{
|
||||||
|
public int LinkQuality { get; set; }
|
||||||
|
public int Battery { get; set; }
|
||||||
|
public int Voltage { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
22
MyCore/Models/Providers/Zigbee/Aqara/AqaraSwitch.cs
Normal file
22
MyCore/Models/Providers/Zigbee/Aqara/AqaraSwitch.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MyCore.Models.Providers.Zigbee.Aqara
|
||||||
|
{
|
||||||
|
public class AqaraSwitch : AqaraDevice
|
||||||
|
{
|
||||||
|
public string Click { get; set; }
|
||||||
|
public int Duration { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/*public enum ClickOptions {
|
||||||
|
single,
|
||||||
|
double,
|
||||||
|
triple,
|
||||||
|
quadruple,
|
||||||
|
long,
|
||||||
|
long_release
|
||||||
|
}*/
|
||||||
|
}
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MyCore.Models.Providers.Zigbee.Zigbee2Mqtt
|
||||||
|
{
|
||||||
|
public class Zigbee2MqttDevice
|
||||||
|
{
|
||||||
|
public string ieeeAddr { get; set; }
|
||||||
|
public string type { get; set; }
|
||||||
|
public int networkAddress { get; set; }
|
||||||
|
public string model { get; set; }
|
||||||
|
public string vendor { get; set; }
|
||||||
|
public string description { get; set; }
|
||||||
|
public string friendly_name { get; set; }
|
||||||
|
public int manufacturerID { get; set; }
|
||||||
|
public string manufacturerName { get; set; }
|
||||||
|
public string powerSource { get; set; }
|
||||||
|
public string modelID { get; set; }
|
||||||
|
public int hardwareVersion { get; set; }
|
||||||
|
public string softwareBuildID { get; set; }
|
||||||
|
public string dateCode { get; set; }
|
||||||
|
public long lastSeen { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -121,6 +121,7 @@ namespace MyCore.Services.Devices
|
|||||||
// TODO Server..
|
// TODO Server..
|
||||||
MQTTService mQTTService = new MQTTService("192.168.31.140", "mqtt", "mqtt");
|
MQTTService mQTTService = new MQTTService("192.168.31.140", "mqtt", "mqtt");
|
||||||
|
|
||||||
|
mQTTService.GetDevices();
|
||||||
}
|
}
|
||||||
catch (UnauthorizedAccessException ex)
|
catch (UnauthorizedAccessException ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -4,6 +4,8 @@ using MQTTnet.Client.Options;
|
|||||||
using MyCore.Models;
|
using MyCore.Models;
|
||||||
using MyCore.Models.Aqara;
|
using MyCore.Models.Aqara;
|
||||||
using MyCore.Models.Ikea;
|
using MyCore.Models.Ikea;
|
||||||
|
using MyCore.Models.Providers.Zigbee.Aqara;
|
||||||
|
using MyCore.Models.Providers.Zigbee.Zigbee2Mqtt;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -25,6 +27,8 @@ namespace MyCore.Services
|
|||||||
|
|
||||||
private LightState lightStateIkeaBulb = LightState.Undefined;
|
private LightState lightStateIkeaBulb = LightState.Undefined;
|
||||||
|
|
||||||
|
public List<Zigbee2MqttDevice> devices = new List<Zigbee2MqttDevice>();
|
||||||
|
|
||||||
// It's here to have the mqtt initialisation + logic for payload..
|
// It's here to have the mqtt initialisation + logic for payload..
|
||||||
|
|
||||||
// Related to which event occurs, a specific action is done.
|
// Related to which event occurs, a specific action is done.
|
||||||
@ -53,6 +57,7 @@ namespace MyCore.Services
|
|||||||
if (res.Status == TaskStatus.RanToCompletion)
|
if (res.Status == TaskStatus.RanToCompletion)
|
||||||
{
|
{
|
||||||
Console.WriteLine("It's connected");
|
Console.WriteLine("It's connected");
|
||||||
|
PublishMessage("zigbee2mqtt/bridge/config/devices/get", "");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -90,13 +95,19 @@ namespace MyCore.Services
|
|||||||
{
|
{
|
||||||
Console.WriteLine("### RECEIVED APPLICATION MESSAGE ###");
|
Console.WriteLine("### RECEIVED APPLICATION MESSAGE ###");
|
||||||
Console.WriteLine($"+ Topic = {e.ApplicationMessage.Topic}");
|
Console.WriteLine($"+ Topic = {e.ApplicationMessage.Topic}");
|
||||||
Console.WriteLine($"+ Payload = {Encoding.UTF8.GetString(e.ApplicationMessage.Payload)}");
|
var payload = "";
|
||||||
|
if (e.ApplicationMessage.Payload != null)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"+ Payload = {Encoding.UTF8.GetString(e.ApplicationMessage.Payload)}");
|
||||||
|
payload = Encoding.UTF8.GetString(e.ApplicationMessage.Payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Console.WriteLine($"+ QoS = {e.ApplicationMessage.QualityOfServiceLevel}");
|
Console.WriteLine($"+ QoS = {e.ApplicationMessage.QualityOfServiceLevel}");
|
||||||
Console.WriteLine($"+ Retain = {e.ApplicationMessage.Retain}");
|
Console.WriteLine($"+ Retain = {e.ApplicationMessage.Retain}");
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
|
|
||||||
var topic = e.ApplicationMessage.Topic;
|
var topic = e.ApplicationMessage.Topic;
|
||||||
var payload = Encoding.UTF8.GetString(e.ApplicationMessage.Payload);
|
|
||||||
|
|
||||||
// As soon as we received all the info =>
|
// As soon as we received all the info =>
|
||||||
//_client.DisconnectAsync();
|
//_client.DisconnectAsync();
|
||||||
@ -120,10 +131,21 @@ namespace MyCore.Services
|
|||||||
// TODO - TO CLARIFY
|
// TODO - TO CLARIFY
|
||||||
switch (topic)
|
switch (topic)
|
||||||
{
|
{
|
||||||
|
case "zigbee2mqtt/bridge/config/devices":
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var test = JsonConvert.DeserializeObject<List<Zigbee2MqttDevice>>(payload);
|
||||||
|
devices = test;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Error during retrieving devices ! Exception: {ex}");
|
||||||
|
}
|
||||||
|
break;
|
||||||
case "zigbee2mqtt/0x00158d00029a7b65":
|
case "zigbee2mqtt/0x00158d00029a7b65":
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var test = JsonConvert.DeserializeObject<Cube>(payload);
|
var test = JsonConvert.DeserializeObject<AqaraCube>(payload);
|
||||||
if (test.Action == "shake")
|
if (test.Action == "shake")
|
||||||
{
|
{
|
||||||
var labLamp = yeelightService.devices.Where(d => d.Hostname == "192.168.31.74").FirstOrDefault();
|
var labLamp = yeelightService.devices.Where(d => d.Hostname == "192.168.31.74").FirstOrDefault();
|
||||||
@ -157,6 +179,32 @@ namespace MyCore.Services
|
|||||||
Console.WriteLine($"Error IkeaLightBulb ! Exception: {ex}");
|
Console.WriteLine($"Error IkeaLightBulb ! Exception: {ex}");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "zigbee2mqtt/0x00158d00035cf1a7":
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var aqaraSwitch = JsonConvert.DeserializeObject<AqaraSwitch>(payload);
|
||||||
|
|
||||||
|
if (aqaraSwitch.Click == "single") {
|
||||||
|
YeelightService yeelighService = new YeelightService();
|
||||||
|
var devicesYeelight = yeelighService.GetDevices().Result;
|
||||||
|
var labLamp = devicesYeelight.Where(light => light.Hostname == "192.168.31.74").FirstOrDefault();
|
||||||
|
if (labLamp != null)
|
||||||
|
yeelightService.Toggle(labLamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aqaraSwitch.Click == "double")
|
||||||
|
{
|
||||||
|
if (lightStateIkeaBulb == LightState.Undefined || lightStateIkeaBulb == LightState.Off)
|
||||||
|
PublishMessage("zigbee2mqtt/0x14b457fffe7628fa/set", "{\"state\": \"ON\"}");
|
||||||
|
else
|
||||||
|
PublishMessage("zigbee2mqtt/0x14b457fffe7628fa/set", "{\"state\": \"OFF\"}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Error Aqara switch ! Exception: {ex}");
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Console.WriteLine("Hello nothing to do here..");
|
Console.WriteLine("Hello nothing to do here..");
|
||||||
break;
|
break;
|
||||||
@ -185,6 +233,11 @@ namespace MyCore.Services
|
|||||||
await _client.PublishAsync(mqttMessage);
|
await _client.PublishAsync(mqttMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Zigbee2MqttDevice> GetDevices()
|
||||||
|
{
|
||||||
|
return devices;
|
||||||
|
}
|
||||||
|
|
||||||
/*protected async Task Start()
|
/*protected async Task Start()
|
||||||
{
|
{
|
||||||
var server = new MqttFactory().CreateMqttServer();
|
var server = new MqttFactory().CreateMqttServer();
|
||||||
|
|||||||
@ -14,7 +14,6 @@ namespace MyCore.Services
|
|||||||
{
|
{
|
||||||
devices = await DeviceLocator.Discover();
|
devices = await DeviceLocator.Discover();
|
||||||
|
|
||||||
//Toggle(devices[1]);
|
|
||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -33,8 +33,12 @@ namespace MyCore
|
|||||||
|
|
||||||
//ArloService arloService = new ArloService();
|
//ArloService arloService = new ArloService();
|
||||||
|
|
||||||
YeelightService yeelighService = new YeelightService();
|
/*YeelightService yeelighService = new YeelightService();
|
||||||
yeelighService.GetDevices();
|
yeelighService.GetDevices();*/
|
||||||
|
|
||||||
|
MQTTService mQTTService = new MQTTService("192.168.31.140", "mqtt", "mqtt");
|
||||||
|
|
||||||
|
mQTTService.GetDevices();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
43
RPI Code/network-monitor.sh
Normal file
43
RPI Code/network-monitor.sh
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# make sure we aren't running already
|
||||||
|
what=`basename $0`
|
||||||
|
for p in `ps h -o pid -C $what`; do
|
||||||
|
if [ $p != $$ ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# source configuration
|
||||||
|
. /etc/wifi.conf
|
||||||
|
|
||||||
|
exec 1> /dev/null
|
||||||
|
exec 2>> $log
|
||||||
|
echo $(date) > $log
|
||||||
|
# without check_interval set, we risk a 0 sleep = busy loop
|
||||||
|
if [ ! "$check_interval" ]; then
|
||||||
|
echo "No check interval set!" >> $log
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
startWifi () {
|
||||||
|
dhclient -v -r
|
||||||
|
# make really sure
|
||||||
|
killall dhclient
|
||||||
|
iwconfig $wlan essid $essid
|
||||||
|
dhclient -v $wlan
|
||||||
|
}
|
||||||
|
|
||||||
|
ifconfig $eth down
|
||||||
|
ifconfig $wlan up
|
||||||
|
startWifi
|
||||||
|
|
||||||
|
while [ 1 ]; do
|
||||||
|
ping -c 1 $router_ip & wait $!
|
||||||
|
if [ $? != 0 ]; then
|
||||||
|
echo $(date)" attempting restart..." >> $log
|
||||||
|
startWifi
|
||||||
|
sleep 1
|
||||||
|
else sleep $check_interval
|
||||||
|
fi
|
||||||
|
done
|
||||||
Loading…
x
Reference in New Issue
Block a user