diff --git a/devices/b-parasite/0400_lightlevel.js b/devices/b-parasite/0400_lightlevel.js new file mode 100644 index 0000000000..2895f3868a --- /dev/null +++ b/devices/b-parasite/0400_lightlevel.js @@ -0,0 +1,10 @@ +/* global Attr, Item, R */ + +const v = Attr.val +const tholddark = R.item('config/tholddark').val +const tholdoffset = R.item('config/tholdoffset').val + +Item.val = v +R.item('state/dark').val = v <= tholddark +R.item('state/daylight').val = v > tholddark + tholdoffset +R.item('state/lux').val = Math.round(Math.pow(10, (Math.max(0, Math.min(v, 60001)) - 1) / 10000)) diff --git a/devices/b-parasite/b-parasite.json b/devices/b-parasite/b-parasite.json new file mode 100644 index 0000000000..4612ff4fc4 --- /dev/null +++ b/devices/b-parasite/b-parasite.json @@ -0,0 +1,415 @@ +{ + "schema": "devcap1.schema.json", + "uuid": "7ad2d274-5bb0-40f1-926b-4d9d059ce393", + "manufacturername": "b-parasite", + "modelid": "b-parasite", + "product": "open source soil moisture and ambient temperature/humidity/light sensor", + "sleeper": true, + "status": "Gold", + "subdevices": [ + { + "type": "$TYPE_TEMPERATURE_SENSOR", + "restapi": "/sensors", + "uuid": [ + "$address.ext", + "0x0a", + "0x0402" + ], + "items": [ + { + "name": "attr/id" + }, + { + "name": "attr/lastannounced" + }, + { + "name": "attr/lastseen" + }, + { + "name": "attr/manufacturername" + }, + { + "name": "attr/modelid" + }, + { + "name": "attr/name" + }, + { + "name": "attr/swversion" + }, + { + "name": "attr/type" + }, + { + "name": "attr/uniqueid" + }, + { + "name": "config/battery", + "refresh.interval": 86400, + "read": { + "at": "0x0021", + "cl": "0x0001", + "ep": 10, + "fn": "zcl:attr" + }, + "parse": { + "at": "0x0021", + "cl": "0x0001", + "ep": 10, + "eval": "Item.val = Attr.val / 2", + "fn": "zcl:attr" + } + }, + { + "name": "config/offset", + "default": 0 + }, + { + "name": "config/on" + }, + { + "name": "config/reachable" + }, + { + "name": "state/lastupdated" + }, + { + "name": "state/temperature", + "parse": { + "at": "0x0000", + "cl": "0x0402", + "ep": 10, + "eval": "Item.val = Attr.val + R.item('config/offset').val", + "fn": "zcl:attr" + }, + "default": 0 + } + ] + }, + { + "type": "$TYPE_HUMIDITY_SENSOR", + "restapi": "/sensors", + "uuid": [ + "$address.ext", + "0x0a", + "0x0405" + ], + "items": [ + { + "name": "attr/id" + }, + { + "name": "attr/lastannounced" + }, + { + "name": "attr/lastseen" + }, + { + "name": "attr/manufacturername" + }, + { + "name": "attr/modelid" + }, + { + "name": "attr/name" + }, + { + "name": "attr/swversion" + }, + { + "name": "attr/type" + }, + { + "name": "attr/uniqueid" + }, + { + "name": "config/battery", + "refresh.interval": 86400, + "read": { + "at": "0x0021", + "cl": "0x0001", + "ep": 10, + "fn": "zcl:attr" + }, + "parse": { + "at": "0x0021", + "cl": "0x0001", + "ep": 10, + "eval": "Item.val = Attr.val / 2", + "fn": "zcl:attr" + } + }, + { + "name": "config/offset", + "default": 0 + }, + { + "name": "config/on" + }, + { + "name": "config/reachable" + }, + { + "name": "state/humidity", + "parse": { + "at": "0x0000", + "cl": "0x0405", + "ep": 10, + "eval": "Item.val = Attr.val + R.item('config/offset').val", + "fn": "zcl:attr" + }, + "default": 0 + }, + { + "name": "state/lastupdated" + } + ] + }, + { + "type": "$TYPE_MOISTURE_SENSOR", + "restapi": "/sensors", + "uuid": [ + "$address.ext", + "0x0a", + "0x0408" + ], + "items": [ + { + "name": "attr/id" + }, + { + "name": "attr/lastannounced" + }, + { + "name": "attr/lastseen" + }, + { + "name": "attr/manufacturername" + }, + { + "name": "attr/modelid" + }, + { + "name": "attr/name" + }, + { + "name": "attr/swversion" + }, + { + "name": "attr/type" + }, + { + "name": "attr/uniqueid" + }, + { + "name": "config/battery", + "refresh.interval": 86400, + "read": { + "at": "0x0021", + "cl": "0x0001", + "ep": 10, + "fn": "zcl:attr" + }, + "parse": { + "at": "0x0021", + "cl": "0x0001", + "ep": 10, + "eval": "Item.val = Attr.val / 2", + "fn": "zcl:attr" + } + }, + { + "name": "config/offset", + "default": 0 + }, + { + "name": "config/on" + }, + { + "name": "config/reachable" + }, + { + "name": "state/lastupdated" + }, + { + "name": "state/moisture", + "parse": { + "at": "0x0000", + "cl": "0x0408", + "ep": 10, + "eval": "Item.val = Attr.val + R.item('config/offset').val", + "fn": "zcl:attr" + }, + "default": 0 + } + ] + }, + { + "type": "$TYPE_LIGHT_LEVEL_SENSOR", + "restapi": "/sensors", + "uuid": [ + "$address.ext", + "0x0a", + "0x0400" + ], + "items": [ + { + "name": "attr/id" + }, + { + "name": "attr/lastannounced" + }, + { + "name": "attr/lastseen" + }, + { + "name": "attr/manufacturername" + }, + { + "name": "attr/modelid" + }, + { + "name": "attr/name" + }, + { + "name": "attr/swversion" + }, + { + "name": "attr/type" + }, + { + "name": "attr/uniqueid" + }, + { + "name": "config/battery", + "refresh.interval": 86400, + "read": { + "at": "0x0021", + "cl": "0x0001", + "ep": 10, + "fn": "zcl:attr" + }, + "parse": { + "at": "0x0021", + "cl": "0x0001", + "ep": 10, + "eval": "Item.val = Attr.val / 2", + "fn": "zcl:attr" + } + }, + { + "name": "config/on" + }, + { + "name": "config/reachable" + }, + { + "name": "config/tholddark", + "default": 12000 + }, + { + "name": "config/tholdoffset", + "default": 7000 + }, + { + "name": "state/dark", + "default": false + }, + { + "name": "state/daylight", + "default": false + }, + { + "name": "state/lastupdated" + }, + { + "name": "state/lightlevel", + "parse": { + "at": "0x0000", + "cl": "0x0400", + "ep": 10, + "fn": "zcl:attr", + "script": "0400_lightlevel.js" + }, + "default": 0 + }, + { + "name": "state/lux", + "default": 0 + } + ] + } + ], + "bindings": [ + { + "bind": "unicast", + "src.ep": 10, + "cl": "0x0402", + "report": [ + { + "at": "0x0000", + "dt": "0x29", + "min": 60, + "max": 3600, + "change": "0x00000032" + } + ] + }, + { + "bind": "unicast", + "src.ep": 10, + "cl": "0x0405", + "report": [ + { + "at": "0x0000", + "dt": "0x21", + "min": 60, + "max": 3600, + "change": "0x00000032" + } + ] + }, + { + "bind": "unicast", + "src.ep": 10, + "cl": "0x0408", + "report": [ + { + "at": "0x0000", + "dt": "0x21", + "min": 60, + "max": 3600, + "change": "0x00000032" + } + ] + }, + { + "bind": "unicast", + "src.ep": 10, + "cl": "0x0400", + "report": [ + { + "at": "0x0000", + "dt": "0x21", + "min": 60, + "max": 3600, + "change": "0x000007D0" + } + ] + }, + { + "bind": "unicast", + "src.ep": 10, + "cl": "0x0001", + "report": [ + { + "at": "0x0021", + "dt": "0x20", + "min": 3600, + "max": 62000, + "change": "0x00000001" + } + ] + } + ] +}