| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- package zigbee2mqtt
- import (
- "encoding/json"
- "fmt"
- )
- type hex int
- /* {
- "ieee_address":"0x00158d00018255df",
- "type":"Router",
- "network_address":29159,
- "supported":true,
- "disabled": false,
- "friendly_name":"my_plug",
- "description":"this plug is in the kitchen",
- "endpoints":{"1":{"bindings":[],"configured_reportings":[],"clusters":{"input":["genOnOff","genBasic"],"output":[]}}},
- "definition":{
- "model":"ZNCZ02LM",
- "vendor":"Xiaomi",
- "description":"Mi power plug ZigBee",
- "options": [...], // see exposes/options below
- "exposes": [...] // see exposes/options below
- },
- "power_source":"Mains (single phase)",
- "date_code":"02-28-2017",
- "model_id":"lumi.plug",
- "scenes": [{"id": 3, "name": "Chill scene"}],
- "interviewing":false,
- "interview_completed":true
- }, */
- /*
- "exposes": [{
- "access": 1,
- "description": "Remaining battery in %",
- "name": "battery",
- "property": "battery",
- "type": "numeric",
- "unit": "%",
- "value_max": 100,
- "value_min": 0
- }
- */
- type expose struct {
- Access int
- Description string
- Name string
- Property string
- Type string
- Unit string
- Value_max int
- Value_min int
- }
- /*
- "target": {
- "endpoint": 1,
- "ieee_address": "0x00124b00229884d8",
- "type": "endpoint"
- }
- */
- type target struct {
- Endpoint int
- Ieee_address string
- Type string
- }
- /*
- "bindings": [{
- "cluster": "genPowerCfg",
- "target": {
- "endpoint": 1,
- "ieee_address": "0x00124b00229884d8",
- "type": "endpoint"
- }
- },
- */
- type binding struct {
- Cluster string
- Target target
- }
- /*
- "clusters": {
- "input": ["genBasic", "genPowerCfg", "genPollCtrl", "touchlink", "64768"],
- "output": ["genIdentify", "genGroups", "genScenes", "genOnOff", "genLevelCtrl", "genOta", "lightingColorCtrl", "touchlink"]
- },
- */
- type clusters struct {
- Input []string
- Output []string
- }
- /*
- "configured_reportings": [{
- "attribute": "batteryVoltage",
- "cluster": "genPowerCfg",
- "maximum_report_interval": 62000,
- "minimum_report_interval": 3600,
- "reportable_change": 0
- }],
- */
- type reportings struct {
- Attribute string
- Cluster string
- Maximum_report_interval int
- Minimum_report_interval json.Number
- Reportable_change int
- }
- /*
- "scenes": []
- */
- type endpoint struct {
- Bindings []binding
- Configured_reportings []reportings
- // Scenes: []
- Scenes []string
- }
- type definition struct {
- Description string
- Exposes []expose
- }
- type device struct {
- Date_code string
- Disabled bool
- Friendly_name string
- Ieee_address string
- Interview_completed bool
- Interviewing bool
- Manufacturer string
- Model_id string
- Network_address int
- Power_source string
- Software_build_id string
- Supported bool
- Type string
- Endpoints map[string]endpoint
- Clusters clusters
- Definition definition
- }
- func Build(data []byte, Z2m *Zigbee2mqtt) {
- //var arr []device
- err := json.Unmarshal(data, &Z2m.Devices)
- fmt.Println("connectors/zigbee2mqtt/device/builder")
- if err != nil {
- panic(err)
- }
- }
|