MacWyznawca / homebridge-mqtt-power-consumption-log-tasmota

Plugin to HomeBridge optimized for work with Itead Sonoff POW hardware with firmware Sonoff-Tasmota via MQTT with log data to file. Partially emulate Elgato Eve Energy. Measure used power and write data to log text files.
MIT License
13 stars 12 forks source link

ReferenceError: data is not defined #2

Open elfnino opened 7 years ago

elfnino commented 7 years ago

Hi, I have used a standart config and I am getting following error:

[5/3/2017, 10:17:05 PM] Loaded plugin: homebridge-mqtt-power-consumption-log-tasmota [5/3/2017, 10:17:05 PM] Registering accessory 'homebridge-mqtt-power-consumption-log-tasmota.mqtt-power-consumption-log -tasmota' [5/3/2017, 10:17:05 PM] --- [5/3/2017, 10:17:06 PM] Loaded plugin: homebridge-mqtt-switch-tasmota [5/3/2017, 10:17:06 PM] Registering accessory 'homebridge-mqtt-switch-tasmota.mqtt-switch-tasmota' [5/3/2017, 10:17:06 PM] --- [5/3/2017, 10:17:06 PM] Loaded config.json with 1 accessories and 0 platforms. [5/3/2017, 10:17:06 PM] --- [5/3/2017, 10:17:06 PM] Loading 0 platforms... [5/3/2017, 10:17:06 PM] Loading 1 accessories... [5/3/2017, 10:17:06 PM] [prvePOW] Initializing mqtt-power-consumption-log-tasmota accessory... Scan this code with your HomeKit App on your iOS device to pair with Homebridge:

ââââââââââââââ
â 031-45-154 â
ââââââââââââââ

[5/3/2017, 10:17:06 PM] Homebridge is running on port 51826. [5/3/2017, 10:17:06 PM] [prvePOW] Nothing to change _hourly [5/3/2017, 10:17:06 PM] [prvePOW] Nothing to change _daily [5/3/2017, 10:17:06 PM] [prvePOW] Nothing to change _period **/usr/local/lib/node_modules/homebridge-mqtt-power-consumption-log-tasmota/index.js:398 data = null; ^

ReferenceError: data is not defined** at MqttClient. (/usr/local/lib/node_modules/homebridge-mqtt-power-consumption-log-tasmota/index.js:398:9 ) at emitThree (events.js:116:13) at MqttClient.emit (events.js:194:7) at MqttClient._handlePublish (/usr/local/lib/node_modules/homebridge-mqtt-power-consumption-log-tasmota/node_module s/mqtt/lib/client.js:821:12) at MqttClient._handlePacket (/usr/local/lib/node_modules/homebridge-mqtt-power-consumption-log-tasmota/node_modules /mqtt/lib/client.js:286:12) at process (/usr/local/lib/node_modules/homebridge-mqtt-power-consumption-log-tasmota/node_modules/mqtt/lib/client. js:242:12) at Writable.writable._write (/usr/local/lib/node_modules/homebridge-mqtt-power-consumption-log-tasmota/node_modules /mqtt/lib/client.js:252:5) at doWrite (/usr/local/lib/node_modules/homebridge-mqtt-power-consumption-log-tasmota/node_modules/readable-stream/ lib/_stream_writable.js:338:64) at writeOrBuffer (/usr/local/lib/node_modules/homebridge-mqtt-power-consumption-log-tasmota/node_modules/readable-s tream/lib/_stream_writable.js:327:5) at Writable.write (/usr/local/lib/node_modules/homebridge-mqtt-power-consumption-log-tasmota/node_modules/readable- stream/lib/_stream_writable.js:264:11)

elfnino commented 7 years ago

Any suggestion what could be wrong ?

swilalaa commented 7 years ago

+1 Same issue here

zhilly commented 6 years ago

i have the same +2

AntiHeld889 commented 6 years ago

i have the same +3

ceraz68 commented 6 years ago

Hi I also get the same issue. Seems to be linked to the URL statement in json file. I'm running mosquitto server on the synology with homebridge within docker. Tried "url" as "mqtt://IP_address" or "mqtt://IP_address:1883" or "IP_address".

Has someone found a workaround or explanation ?

ceraz68 commented 6 years ago

I validated my MQTT setup using the homebridge-mqtt-switch-tasmota plugin which works fine. For the homebridge-mqtt-power-consumption-log-tasmota plugin I got access errors as the log files try to write to /root/.homebridge so I changed to the docker folder. When they were resolved back to the original error **/usr/local/lib/node_modules/homebridge-mqtt-power-consumption-log-tasmota/index.js:398 data = null; ^

Giorgiofox commented 6 years ago

same error here: /usr/local/lib/node_modules/homebridge-mqtt-power-consumption-log-tasmota/index.js:398 data = null; ^ ReferenceError: data is not defined at MqttClient. (/usr/local/lib/node_modules/homebridge-mqtt-power-consumption-log-tasmota/index.js:398:9) at emitThree (events.js:116:13) at MqttClient.emit (events.js:197:7) at MqttClient._handlePublish (/usr/local/lib/node_modules/homebridge-mqtt-power-consumption-log-tasmota/node_modules/mqtt/lib/client.js:935:12) at MqttClient._handlePacket (/usr/local/lib/node_modules/homebridge-mqtt-power-consumption-log-tasmota/node_modules/mqtt/lib/client.js:305:12) at work (/usr/local/lib/node_modules/homebridge-mqtt-power-consumption-log-tasmota/node_modules/mqtt/lib/client.js:261:12) at Writable.writable._write (/usr/local/lib/node_modules/homebridge-mqtt-power-consumption-log-tasmota/node_modules/mqtt/lib/client.js:271:5) at doWrite (/usr/local/lib/node_modules/homebridge-mqtt-power-consumption-log-tasmota/node_modules/readable-stream/lib/_stream_writable.js:406:64) at writeOrBuffer (/usr/local/lib/node_modules/homebridge-mqtt-power-consumption-log-tasmota/node_modules/readable-stream/lib/_stream_writable.js:395:5) at Writable.write (/usr/local/lib/node_modules/homebridge-mqtt-power-consumption-log-tasmota/node_modules/readable-stream/lib/_stream_writable.js:322:11) at Socket.ondata (_stream_readable.js:555:20) at emitOne (events.js:96:13) at Socket.emit (events.js:191:7) at readableAddChunk (_stream_readable.js:176:18) at Socket.Readable.push (_stream_readable.js:134:10) at TCP.onread (net.js:554:20)

Giorgiofox commented 6 years ago

Solved: https://github.com/MacWyznawca/homebridge-mqtt-power-consumption-log-tasmota/pull/4/commits