iotux / ElWiz

ElWiz - a program to read data from Tibber Pulse and similar devices
MIT License
109 stars 16 forks source link

Bug Report - TypeError: Cannot read properties of undefined (reading '15') #27

Closed oysan closed 2 months ago

oysan commented 3 months ago

I encountered an issue while starting Elwiz. The application crashes with a TypeError when attempting to access spotPrice from dayPrices.hourly[idx] in the mergeprices.js file.

/opt/ElWiz/plugin/mergeprices.js:175
    obj.spotPrice = dayPrices.hourly[idx].spotPrice;
                                    ^

TypeError: Cannot read properties of undefined (reading '15')
    at mergePrices (/opt/ElWiz/plugin/mergeprices.js:175:37)
    at EventEmitter.onPlugEvent2 (/opt/ElWiz/plugin/plugselector.js:33:15)
    at EventEmitter.emit (node:events:517:28)
    at EventEmitter.listHandler (/opt/ElWiz/ams/kaifa.js:123:9)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v18.19.1
iotux commented 3 months ago

Thanks for pointing out. I will push an update shortly. It would be useful if you provide some information about your installation.

Is this a first time installation or an update? Is at a Github or Docker installation? Which brand and version is your AMS meter? Is your mains supply one phase or 3 phases?

If your intstallation is an update, you may need to go through config.yaml and check your params. As a safeguard, you can copy your original to a backup and copy "config.yaml.sample" to "config.yaml" and reestablish your actual params.

It is important that prices are available whe ElWiz is starting. When starting everything with "pm2 start pm2-run.json", the prices should normally be there in time.

It may be helpful to join the ElWiz Discord https://discord.gg/VNfywU8v and message on the #elwiz-user channel

oysan commented 3 months ago

I apologize for the oversight. I didn't thoroughly read the entire README and missed the pm2run.json. I started everything manually instead. Using pm2 start pm2run.json resolves the issue.

iotux commented 3 months ago

I pushed a new version an hour ago. It may be worth it to do a git pull.