added model and manufacturer
This commit is contained in:
@@ -15,20 +15,20 @@ module.exports.setup = async (mqtt) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.publishDevice = async (deviceid,device_name,config) => {
|
module.exports.publishDevice = async (device,config) => {
|
||||||
// deviceid: unique device id, ideally based on the tuya device id
|
// deviceid: unique device id, ideally based on the tuya device id
|
||||||
// device_name: firendlyname displayed in the gui
|
// device_name: firendlyname displayed in the gui
|
||||||
// config: device config
|
// config: device config
|
||||||
|
|
||||||
let unique_identifier = `luminea2mqtt_${deviceid}`
|
let unique_identifier = `luminea2mqtt_${device.deviceid}`
|
||||||
Object.keys(config).forEach(component =>{
|
Object.keys(config).forEach(component =>{
|
||||||
|
|
||||||
let items = config[component]
|
let items = config[component]
|
||||||
Object.keys(items).forEach(item =>{
|
Object.keys(items).forEach(item =>{
|
||||||
let mqtt_topic = `${configldr.config.autodiscover.topic}/${component}/${deviceid}/${item}/config`
|
let mqtt_topic = `${configldr.config.autodiscover.topic}/${component}/${device.deviceid}/${item}/config`
|
||||||
let temp_data = JSON.parse(JSON.stringify(config[component][item]))
|
let temp_data = JSON.parse(JSON.stringify(config[component][item]))
|
||||||
temp_data.unique_id = `${deviceid}_${item}_luminea2mqtt`
|
temp_data.unique_id = `${device.deviceid}_${item}_luminea2mqtt`
|
||||||
temp_data.object_id = `${device_name}_${item}`
|
temp_data.object_id = `${device.friendlyname}_${item}`
|
||||||
temp_data.origin = {
|
temp_data.origin = {
|
||||||
name : "luminea2mqtt",
|
name : "luminea2mqtt",
|
||||||
support_url: "https://github.com/dennis9819/luminea2mqtt"
|
support_url: "https://github.com/dennis9819/luminea2mqtt"
|
||||||
@@ -37,9 +37,9 @@ module.exports.publishDevice = async (deviceid,device_name,config) => {
|
|||||||
identifiers : [
|
identifiers : [
|
||||||
unique_identifier
|
unique_identifier
|
||||||
],
|
],
|
||||||
name: device_name,
|
name: device.friendlyname,
|
||||||
manufacturer: "dennisgunia",
|
manufacturer: device.manufacturer ? device.manufacturer : "Unkown",
|
||||||
model: "Unknown",
|
model: device.model ? device.model : "Unkown",
|
||||||
|
|
||||||
//via_device: `luminea2mqtt_bridge_${configldr.config.mqtt.devenv1}`
|
//via_device: `luminea2mqtt_bridge_${configldr.config.mqtt.devenv1}`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ class DeviceBase {
|
|||||||
|
|
||||||
pushAutodiscover(config){
|
pushAutodiscover(config){
|
||||||
if (configldr.config.autodiscover.enabled){
|
if (configldr.config.autodiscover.enabled){
|
||||||
autodiscover.publishDevice(this.deviceid,this.friendlyname,config)
|
autodiscover.publishDevice(this,config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +104,6 @@ class DeviceBase {
|
|||||||
this.device.find().then(el => {
|
this.device.find().then(el => {
|
||||||
if (el) {
|
if (el) {
|
||||||
this.device.connect().catch(el => {
|
this.device.connect().catch(el => {
|
||||||
console.log(this.device)
|
|
||||||
this.logger.debug("Reconnect failed: device offline")
|
this.logger.debug("Reconnect failed: device offline")
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ const DeviceBase = require('../devicebase')
|
|||||||
class Lineplug extends DeviceBase {
|
class Lineplug extends DeviceBase {
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
|
this.manufacturer = "Luminea"
|
||||||
|
this.model = "NX-4458"
|
||||||
this.lastdata = {
|
this.lastdata = {
|
||||||
voltage: 0,
|
voltage: 0,
|
||||||
current: 0,
|
current: 0,
|
||||||
@@ -129,7 +131,7 @@ class Lineplug extends DeviceBase {
|
|||||||
changed = true
|
changed = true
|
||||||
}
|
}
|
||||||
if (updatedValues.includes('17')) {
|
if (updatedValues.includes('17')) {
|
||||||
this.lastdata.power = dps['17'] / 100
|
this.lastdata.work = dps['17'] / 100
|
||||||
changed = true
|
changed = true
|
||||||
}
|
}
|
||||||
if (updatedValues.includes('9')) {
|
if (updatedValues.includes('9')) {
|
||||||
|
|||||||
Reference in New Issue
Block a user