autoSteve / acMqtt

CBus Automation Controller: Home Assistant, MQTT, Philips Hue and more (for the SHAC/NAC/AC2/NAC2)
GNU General Public License v3.0
15 stars 6 forks source link

Resident script:294: attempt to index a nil value #53

Closed OrigSorceror closed 2 months ago

OrigSorceror commented 2 months ago

using the current MQTT send receive script but getting this error in my SHAC5500 error logs

Resident script:294: attempt to index a nil value stack traceback: Resident script:294: in function [C]: in function 'loop'

MQTT successfully connects to broker. but no devices are picked up in HAOS. 5500SHAC Firmware Version 1.6.0 5500SHAC HW version 1.0

autoSteve commented 2 months ago

Change line 294 and restart.

Old:

      if parts[3]:contains('cbus_mqtt_') then

New:

      if parts[3] ~= nil and parts[3]:contains('cbus_mqtt_') then

What I think is going on here is that you likely have a HA discovery topic (something like homeassistant/sensor) that does not contain any sub-topics. This can be verified in MQTT Explorer, but it makes sense.

image
OrigSorceror commented 2 months ago

Ok that fixed the error, but still nothing being reported in HAOSNo new devices found and no nee entries in Mosquito. Sent from my iPhoneOn 14 Aug 2024, at 10:36 AM, Steve Saunders @.***> wrote: Change line 294 and restart. Old: if parts[3]:contains('cbusmqtt') then

New: if parts[3] ~= nil and parts[3]:contains('cbusmqtt') then

What I think is going on here is that you likely have a HA discovery topic (something like homeassistant/sensor) that does not contain any sub-topics. This can be verified in MQTT Explorer, but it makes sense. image.png (view on web)

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

autoSteve commented 2 months ago

Oh come on, @OrigSorceror. You are going to need to provide a HEAP more information, otherwise I am just guessing and probably can't help. One line descriptions from an iPhone saying, "it works but it don't work" give me nothing.

That this error even occurred hints at something not being right with the HA discovery topics.

OrigSorceror commented 2 months ago

ok made code change to turn on logging. nothing in error logs. Log show image ..

MQTT Explorer shows image

OrigSorceror commented 2 months ago

I may not have Mosquitto set up correctly in HAOS. AS there is no HomeAssistant section in the explorer like yours. I also operate the CBUS network on a different Physical network with only a router and Rpi bridging the 2 networks.. currently whilst building this HAOS implementation, i have allowed all traffic between all IPs on both Networks so i doubt it is a network issue..

I halso have CBUS up and running via Homebridge tied in to Apple at the moment whilst i play with the HAOS (have not enable apple integration on HA as yet)

Fairly new to HA, so still getting toes wet on it..

autoSteve commented 2 months ago

Looks like HomeAssistant is not configured for MQTT.

There are no discovery topics at all.

Did you miss this in configuration.yaml?

mqtt:
OrigSorceror commented 2 months ago

nope that is in there just made some changes to the config.yaml and restarting HAOS to apply..

autoSteve commented 2 months ago

What keywords are added to the SHAC objects? Example:

MQTT, light, sa=Family Room, pn=Family Room Lights, 
OrigSorceror commented 2 months ago

Bingo!!! missing keywords. LOL must have glossed over that section of the setup instructions Sorry little dyslexic :(

OrigSorceror commented 2 months ago

just added keywords to 1 of the lights and it is discovered. :) All good to close issue

autoSteve commented 2 months ago

Cheers.