local device = {} device.model = "MG-GPO04ZSLP" device.vendor = "Tuya" device.description = "2 x socket + 1 x light with master switch and metering" device.exposes = { { type = "switch", description = "Master switch controlling all relays", endpoint = "master", features = { { type = "binary", name = "state", property = "state_master", access = 3, value_on = "ON", value_off = "OFF", description = "On/off state of the switch", endpoint = "master", }, }, }, { type = "switch", description = "Light relay", endpoint = "light", features = { { type = "binary", name = "state", property = "state_light", access = 3, value_on = "ON", value_off = "OFF", description = "On/off state of the switch", endpoint = "light", }, }, }, { type = "switch", description = "Left socket", endpoint = "left", features = { { type = "binary", name = "state", property = "state_left", access = 3, value_on = "ON", value_off = "OFF", description = "On/off state of the switch", endpoint = "left", }, }, }, { type = "switch", description = "Right socket", endpoint = "right", features = { { type = "binary", name = "state", property = "state_right", access = 3, value_on = "ON", value_off = "OFF", description = "On/off state of the switch", endpoint = "right", }, }, }, { type = "numeric", name = "voltage", property = "voltage", access = 1, unit = "V", description = "Line voltage reported by the outlet", }, { type = "numeric", name = "current", property = "current", access = 1, unit = "A", description = "Line current reported by the outlet", }, { type = "numeric", name = "energy_wh", property = "energy_wh", access = 1, unit = "Wh", description = "Accumulated energy (raw Wh counter)", }, } device.fromZigbee = { "electrical" } device.tuyaDatapoints = { { dp = 1, name = "state_right", converter = "onOff" }, { dp = 2, name = "state_light", converter = "onOff" }, { dp = 3, name = "state_left", converter = "onOff" }, { dp = 13, name = "state_master", converter = "onOff" }, { dp = 21, name = "current", converter = "divideBy1000" }, { dp = 22, name = "energy_wh", converter = "raw" }, { dp = 23, name = "voltage", converter = "divideBy10" }, } device.configure = { bind = { "haElectricalMeasurement" }, reporting = { { cluster = "haElectricalMeasurement", attribute = "activePower", min = 5, max = 3600, change = 1, }, { cluster = "haElectricalMeasurement", attribute = "rmsVoltage", min = 5, max = 3600, change = 5, }, { cluster = "haElectricalMeasurement", attribute = "rmsCurrent", min = 5, max = 3600, change = 100, }, }, } device.meta = { multiEndpoint = true } device.fingerprint = { { model = "TS0601", manufacturer = "_TZE200_oyti2ums", }, } return device