dchesterton/texecom2mqtt-hassio

Sensors unavailable

Closed this issue · 44 comments

Describe the bug

Sensors unavailable, despite being able to see state change in add-on > texecom2mqtt > Logs

Application version
1.1.6

Texecom alarm type
Premier Elite 24 (V5.04.01LS1)

Home Assistant version

core-2021.11.4

Debug log

No read debug.... log updates when event has triggered.

2021-11-17 16:31:08 - INFO: Kitchen PIR status changed to Active
2021-11-17 16:31:08 - DEBUG: Publishing to texecom2mqtt/zone/kitchen_pir: {"name":"Kitchen PIR","number":4,"areas":["A"],"status":1,"type":"Guard"}
2021-11-17 16:31:12 - INFO: Kitchen PIR status changed to Secure
2021-11-17 16:31:12 - DEBUG: Publishing to texecom2mqtt/zone/kitchen_pir: {"name":"Kitchen PIR","number":4,"areas":["A"],"status":0,"type":"Guard"}
2021-11-17 16:31:14 - DEBUG: Updating system power...
2021-11-17 16:31:14 - DEBUG: Publishing to texecom2mqtt/power:

Believe I have the same issue. Log appears to update on zone status change but no entries created for the sensors under the texecom2mqtt device?

2021-11-17 23:48:41 - INFO: Starting texecom2mqtt v1.1.6...
2021-11-17 23:48:41 - INFO: Connected to alarm, sleeping for 1 second...
2021-11-17 23:48:42 - INFO: Connection ready
2021-11-17 23:48:42 - INFO: Fetched serial number: *******
2021-11-17 23:48:42 - INFO: Logging in
2021-11-17 23:48:42 - INFO: Successfully logged in
2021-11-17 23:48:43 - INFO: Connected to MQTT
2021-11-17 23:48:43 - INFO: Fetched panel info: Premier Elite 24 (V4.03.00LS1)
2021-11-17 23:48:44 - INFO: Fetched Area A: House Area
2021-11-17 23:48:44 - INFO: Fetched Area B: Shed Area
.........
2021-11-17 23:48:53 - INFO: Updating all area states...
2021-11-17 23:48:53 - INFO: Application ready
2021-11-18 00:01:30 - INFO: 1st Floor PIR status changed to Active
2021-11-18 00:01:38 - INFO: 1st Floor PIR status changed to Secure

Interestingly if I listen to texecom2mqtt/status I get the following.... despite everything being online and functioning via the app, and receiving status messages frm the "log"

Message 0 received on texecom2mqtt/status at 14:05:
offline

I believe I also have this problem

I've just got this installed and working (after adding a ComWIFI to my panel to defeat the single-tcp-connection farce of the SmartCom). All was working gloriously and then it stopped. Can't say that I did anything other than maybe restarted HA as part of some unrelated config changes

image

2021-11-26 20:49:20 - INFO: Starting texecom2mqtt v1.1.6...
2021-11-26 20:49:21 - INFO: Connected to alarm, sleeping for 1 second...
2021-11-26 20:49:22 - INFO: Connection ready
2021-11-26 20:49:22 - INFO: Fetched serial number: XXXXXX
2021-11-26 20:49:22 - INFO: Logging in
2021-11-26 20:49:22 - INFO: Successfully logged in
2021-11-26 20:49:22 - INFO: Connected to MQTT
2021-11-26 20:49:23 - INFO: Fetched panel info: Premier Elite 64 (V5.00.03LS1)
2021-11-26 20:49:27 - INFO: Fetched Area A: Whole house
2021-11-26 20:49:27 - INFO: Fetched Area B: Area B
2021-11-26 20:49:27 - INFO: Fetched Area C: Area C
2021-11-26 20:49:27 - INFO: Fetched Area D: Area D
2021-11-26 20:49:40 - INFO: Fetched Zone 9: Front Door (Type: Entry/Exit 1; Areas: A)
2021-11-26 20:49:41 - INFO: Fetched Zone 10: Office (Type: Guard; Areas: A)
...
2021-11-26 20:50:11 - INFO: Updating all zone states...
2021-11-26 20:50:12 - INFO: Updating all area states...
2021-11-26 20:50:12 - INFO: Application ready

All devices showing as Unavailable.

These are in my moquitto logs after a successful looking boot sequence, i'm assuming these are from thids addin as i dont have any other MQTT devices configured yet (but I'm a HA noob, maybe these are some default internals or some other such red herring)

1637961204: New connection from 172.30.32.2 on port 1883.
1637961204: Socket error on client <unknown>, disconnecting.
1637961324: New connection from 172.30.32.2 on port 1883.
1637961324: Socket error on client <unknown>, disconnecting.
1637961444: New connection from 172.30.32.2 on port 1883.
1637961444: Socket error on client <unknown>, disconnecting.
1637961532: Saving in-memory database to /data/mosquitto.db.
1637961564: New connection from 172.30.32.2 on port 1883.
1637961564: Socket error on client <unknown>, disconnecting.
1637961684: New connection from 172.30.32.2 on port 1883.
1637961684: Socket error on client <unknown>, disconnecting.
1637961804: New connection from 172.30.32.2 on port 1883.
1637961804: Socket error on client <unknown>, disconnecting.
1637961924: New connection from 172.30.32.2 on port 1883.
1637961924: Socket error on client <unknown>, disconnecting.
1637962044: New connection from 172.30.32.2 on port 1883.
1637962044: Socket error on client <unknown>, disconnecting.

I am glad it’s not just me, my addon also struggles to connect to the unit first time and sometimes fails to retrieve the serial number and exits out - not sure if some timeout setting needs to be adjusted here.

Just to be clear my HA server is hard wired into same switch as texe connect unit and I have no issue with the texecom unit establishing a connection.

I'm happy to help debug this, where is the actual code?

I think the problem is that the texecom API is under NDA so not publicly available, but guess nothing stopping you from pulling the docker image and having a poke.

Maybe worth signing the NDA so original author can share code code with you if the agreement allows.

Oh yeah, I remember reading that on a thread somewhere.

Do you know how to get mqqt explorer to show what's going on? I've connected it to my ha instance and I see it connect in the mqtt logs, but nothing ever shows in it

Unsure outside of the topic listener in the mqtt plug-in.

I expect there is some code that is conditionally ran when texecom2mqtt/status is “online” and shows sensors as unavailable when showing “offline”.

maybe something has changed in the texecom API recently.

Could you both kindly post your config? It might help to debug the issue

texecom:
  host: 192.168.XXX.XXX
  udl_password: 'XXXX'
mqtt:
  host: core-mosquitto
homeassistant:
  discovery: true
areas: []
zones: []

Not sure if its related but on restarting the add-on I occasionally get this:

2021-11-28 12:58:05 - INFO: Starting texecom2mqtt v1.1.6...
2021-11-28 12:58:05 - INFO: Connected to alarm, sleeping for 1 second...
2021-11-28 12:58:06 - INFO: Connection ready
2021-11-28 12:58:06 - INFO: Fetched serial number: 48
2021-11-28 12:58:06 - INFO: Logging in
/snapshot/app/dist/texecom/texecom.js:81
            throw new Error(`Unexpected start, expected 't', got 0x${headerStart.toString(16)}`);
            ^
Error: Unexpected start, expected 't', got 0x41
    at Texecom.parseBuffer (/snapshot/app/dist/texecom/texecom.js:81:19)
    at Socket.<anonymous> (/snapshot/app/dist/texecom/texecom.js:32:18)
    at Socket.emit (events.js:315:20)
    at addChunk (_stream_readable.js:295:12)
    at readableAddChunk (_stream_readable.js:271:9)
    at Socket.Readable.push (_stream_readable.js:212:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:186:23)

Also notice "48" is not my panels serial number

Yeah that's a known issue where the panel sometimes sends corrupt data when re-connecting. I'm hoping to fix at some point but it's unrelated.

Could you try adding a clientId to your config? So it will be:

texecom:
  host: 192.168.XXX.XXX
  udl_password: 'XXXX'
mqtt:
  host: core-mosquitto
  client_id: texecom2mqtt
homeassistant:
  discovery: true
areas: []
zones: []

If you could add that and then let me know if that fixes it, that would be much appreciated.

Updated config as above, restarted Add-On, get positive logs.
Everything still unavailable.

Restarted whole of HA and still no joy

Edit:

Althought it looks like it briefly worked

image

Can't promise on these timings but maybe it worked after the config change but before the reboot?

5605C667-71FF-4FF8-99A3-CF7D5CF5B41F

my config pretty much the same. Is there any higher level of debug logging available?

@dchesterton I've added log: debug to mine also, and the "successful" logs are now full of debug intel - is this of any use to you? Will DM if so to avoid posting publically if thats ok

Yeah, it definitely could be useful. Please feel free to DM it

Emailed you some logs. LMK how else I can be useful. Cheers!

How’s things looking with this issue ? Can be of any assistance testing, providing more debug logs?

I've had a look at the logs and I can't figure out anything immediately wrong.

I believe the root problem is that the texecom2mqtt/status topic is getting set to offline which causes Home Assistant to show the sensors/alarms as unavailable.

When the app connects to the MQTT broker it configures a "last will" message which sets the topic to offline if/when the app disconnects unexpectedly.

My assumption is that the app might be losing connection to MQTT, the MQTT broker publishes the last will message, the app then recovers the connection but it doesn't re-publish the status. Unfortunately, I can't replicate this behaviour so I'm somewhat guessing.

I've pushed an update which adds some additional logging around the MQTT connection. If you could kindly send the new debug logs when the issue happens again it'd be much appreciated. Also, if you can let me know what the value of the texecom2mqtt/status topic is at the time (I normally use MQTT Explorer for this sort of thing) that'd help.

Installed the update and its working. (interestingly i tried uninstalling and reinstalling the previous version and that didn't cure it)

Ive saved the boot logs, I'll supply them and logs of a broken boot when it happens.

Thanks for your efforts!

Not working for me I’m afraid still.

One thing I do notice is that it never connects first time for me.

29367E3C-7A77-44E9-BFF7-74B2707BD4E5

Could it be possible that it’s setting the status to offline but then never setting it back to online?

I’ll send you over my debug logs, currently running in trace logging level.

Mutliple restarts later and its still working for me 🤷
Will report back (presumably immediately after posting this knowing my luck) when it breaks

I’ve made some configuration changes, replaced “core-mosquitto” with the IP of my HA install and also declared the credentials stored in the mosquitto addon in the texecom2mqtt config and seems to be a little more stable and has endured a number of reboots perhaps there was some race conditions.

Will monitor over next few days.

If you are building the docker image from alpine, please consider buster-slim.

There’s been a spate of recent issues with alpine over the last 12 months with DNS issues.

Seems to be running stable since my configuration changes.

Just to update from me, I think this is working now (having done nothing except installing the debug build).

However, Its currently offline for me but I think thats due to some unrelated network changes I made. I don't have time to investigate this for a few weeks due to Christmas but I shall report back asap with an update.

OK, had a moment to look at this and its definitely still broken :(

Logs look like this:

2021-12-12 12:52:58 - DEBUG: Updating system power...
2021-12-12 12:52:58 - DEBUG: Publishing to texecom2mqtt/status: online
2021-12-12 12:52:58 - DEBUG: Publishing to texecom2mqtt/power: {"battery_charging_current":9,"battery_voltage":13.63,"panel_current":261,"panel_voltage":13.7}

but all the sensors are Unavailable :(

mqtt logs:

1639751767: New connection from 172.30.33.5 on port 1883.
1639751767: New client connected from 172.30.33.5 as texecom2mqtt (p2, c1, k60).
1639751783: Socket error on client texecom2mqtt, disconnecting.
1639751786: New connection from 172.30.33.5 on port 1883.
1639751786: New client connected from 172.30.33.5 as texecom2mqtt (p2, c1, k60).
1639751804: Client texecom2mqtt disconnected.
1639751924: New connection from 172.30.33.5 on port 1883.
1639751924: New client connected from 172.30.33.5 as texecom2mqtt (p2, c1, k60).
1639751942: Client texecom2mqtt disconnected.

My logs now look like this:

2021-12-17 14:42:17 - INFO: Starting texecom2mqtt v1.1.8 (Node v16.13.0)...
2021-12-17 14:42:17 - INFO: Connected to alarm, sleeping for 1 second...
2021-12-17 14:42:18 - INFO: Connection ready
2021-12-17 14:42:18 - DEBUG: Executing serial number command
2021-12-17 14:42:18 - INFO: Fetched serial number: XXXXXXXX
2021-12-17 14:42:18 - INFO: Logging in
2021-12-17 14:42:19 - ERROR: Could not log in
2021-12-17 14:42:19 - DEBUG: Ending socket connection to panel
2021-12-17 14:42:19 - DEBUG: Socket connection to panel ended
2021-12-17 14:42:19 - DEBUG: Panel socket closed
2021-12-17 14:42:19 - DEBUG: Publishing to texecom2mqtt/status: online
2021-12-17 14:42:19 - INFO: Connected to MQTT: core-mosquitto:1883 (retain: true, clean: true, client_id: texecom2mqtt, qos: 0)
2021-12-17 14:42:22 - DEBUG: Command 22 timed out (attempt 1, id: 1).
2021-12-17 14:42:26 - DEBUG: Command 22 timed out (attempt 2, id: 1).
2021-12-17 14:42:29 - DEBUG: Command 22 timed out (attempt 3, id: 1).
2021-12-17 14:42:33 - DEBUG: Command 22 timed out (attempt 4, id: 1).
2021-12-17 14:42:36 - DEBUG: Command 22 timed out (attempt 5, id: 1).
2021-12-17 14:42:36 - ERROR: Unhandled rejection - Command 22 timed out 5 times and could not be completed
2021-12-17 14:42:36 - DEBUG: Publishing to texecom2mqtt/status: offline

Logs are back to this, having done nothing:

2021-12-18 15:06:17 - DEBUG: Updating system power...
2021-12-18 15:06:18 - DEBUG: Publishing to texecom2mqtt/status: online
2021-12-18 15:06:18 - DEBUG: Publishing to texecom2mqtt/power: {"battery_charging_current":0,"battery_voltage":13.63,"panel_current":261,"panel_voltage":13.7}
2021-12-18 15:07:07 - DEBUG: Updating system power...
2021-12-18 15:07:08 - DEBUG: Publishing to texecom2mqtt/status: online
2021-12-18 15:07:08 - DEBUG: Publishing to texecom2mqtt/power: {"battery_charging_current":0,"battery_voltage":13.63,"panel_current":261,"panel_voltage":13.7}
2021-12-18 15:07:57 - DEBUG: Updating system power...
2021-12-18 15:07:58 - DEBUG: Publishing to texecom2mqtt/status: online
2021-12-18 15:07:58 - DEBUG: Publishing to texecom2mqtt/power: {"battery_charging_current":0,"battery_voltage":13.63,"panel_current":261,"panel_voltage":13.7}

All sensors still unavailable

Can you update to the latest version v1.1.9 released yesterday (if you haven't already) and send me the full log from restarting the container until there's a problem? I fixed a couple of bugs and added some additional logging so I'm hoping it might shed some more light on the problem 🤞

Fantastic will try tomorrow, cheers

I've emailed you 👍

I've also uninstalled and reinstalled both mosquitto and texecom2mqtt and get the same "unavailable"ness.

Am I being daft in some other way? Would you humour me and check I haven't been monumentally stupid somehow? (Quite likely)

I've maybe got somewhere with this, or at least got some more information.

So I updated the firmware on my panel, but noticed it was still showing the old version in HA.

Under Integrations the Mosquitto card was showing the texecom device/entities:

image

Viewing these showed the old version, hoping it would force some refresh I deleted these using the delete button previously shown on that card. I then deleted everything texecom related using MQTT Explorer.
I then updated to the latest texecom2mqtt and restarted everything.

MQTT Explorer is now showing this:

image

which agrees with the texecom2mqtt logs.

So why isn't mqtt discovery working? I've set

mqtt:
  discovery: true

in the main HA config to try and force it on but I still don't have any alarm entities. The texecom2mqtt device page shows this:

image

expanding the Disabled Sensors shows this:

image

Is this a clue or have I gone down some rabbit hole?

Which rocks should I lift up next?

Thanks

Sorry, wasnt super clear with my inference there, what I meant to suggest was:

I think my "offline" entities might have been legacy ones from some previous time where they were really offline, and that some combination of uninstalling/reinstalling MQTT/T2MQTT disconnected/lost/didnt-reinstate the entities, so the published MQTT values were probably always right throughout the duration of this thread, but HA wasn't picking up the new/current entities.

Does that make sense?

I'm trying to see why that might be, but im new to this area, I'll keep digging.

Hopefully @dchesterton you know where the "discovery" messages are supposed to be/need to be, maybe thats where this bug really lies

So, it seems my HA instance hasnt been reliably talking to Mosquitto. Despite not touching this aspect, it obviously once worked as the entities were once discovered, and it periodically worked, as the alarm was randomly "online" every now and then.

Sigh

I shall donate time-wasting beers as well as great-project beers.

I'll not close this just yet as the issue may remain, but i suspect for me that this was the problem....

With each release this has become more stable.

Hope this last bug that you squashed (Fix issue where keepalive fails causing the app to hang) fixes the minor issue of it hanging every couple of days requiring the addon needing to restarted

I'm going to close this issue as I think it was a combination of your MQTT/HA issues and the keepalive bug which has now been fixed. Please feel free to re-open if you have any further issues.

I'm going to close this issue as I think it was a combination of your MQTT/HA issues and the keepalive bug which has now been fixed. Please feel free to re-open if you have any further issues.

Perfectly reasonably. Its been stable so far, I'll report back if anything happens

Just to feed back on this, been continuously up for days now, looks fixed 👍

Again, been up for weeks now, no issues

trullock, sorry for bringing this thread back to life. I've been at this for days now and just cant understand why I can only see the first six of my binary sensors! I get a clean start up

2024-04-10 19:42:01 - INFO: Starting texecom2mqtt v1.2.3 (Node v16.13.0)...
2024-04-10 19:42:02 - INFO: Connected to alarm, sleeping for 2 seconds...
2024-04-10 19:42:04 - DEBUG: Executing serial number command
2024-04-10 19:42:04 - INFO: Connection ready
2024-04-10 19:42:04 - INFO: Logging in to panel
2024-04-10 19:42:04 - INFO: Successfully logged in to panel
2024-04-10 19:42:04 - INFO: Connected to MQTT broker: xx.xx.xx.xx+:1883 (retain: true, clean: true, client_id: texecom2mqtt, qos: 2)
2024-04-10 19:42:04 - DEBUG: Publishing to texecom2mqtt/status: online
2024-04-10 19:42:04 - INFO: Serial number: xxxxxxx
2024-04-10 19:42:04 - INFO: Panel: Premier Elite 64 (V5.06.00LS1)
2024-04-10 19:42:05 - INFO: Fetched Area A: Entire House
2024-04-10 19:42:05 - INFO: Fetched Area B: Area B
2024-04-10 19:42:05 - INFO: Fetched Area C: Area C
2024-04-10 19:42:05 - INFO: Fetched Area D: Area D
2024-04-10 19:42:08 - INFO: Fetched Zone 10: Garage Door (Type: Guard; Areas: A)
2024-04-10 19:42:08 - INFO: Fetched Zone 11: Front Room Patio Door (Type: Guard; Areas: A)
2024-04-10 19:42:08 - INFO: Fetched Zone 12: Family Room Patio Door (Type: Guard; Areas: A)
2024-04-10 19:42:09 - INFO: Fetched Zone 13: Back Door (Type: Guard; Areas: A)
2024-04-10 19:42:09 - INFO: Fetched Zone 14: Family Room PIR (Type: Guard; Areas: A)
2024-04-10 19:42:09 - INFO: Fetched Zone 15: Garage PIR (Type: Guard; Areas: A)
2024-04-10 19:42:10 - INFO: Fetched Zone 16: Landing PIR (Type: Guard; Areas: A)
2024-04-10 19:42:10 - INFO: Fetched Zone 17: Front Door (Type: Entry/Exit 1; Areas: A)
2024-04-10 19:42:10 - INFO: Fetched Zone 18: Hall PIR (Type: Entry/Exit 1; Areas: A)
2024-04-10 19:42:11 - INFO: Fetched Zone 19: Master Bedroom Patio Door (Type: Guard; Areas: A)
2024-04-10 19:42:11 - INFO: Fetched Zone 20: Front Sounder (Type: Custom; Areas: A)
2024-04-10 19:42:11 - INFO: Fetched Zone 21: Garage Sounder (Type: Custom; Areas: A)

I can then see the MQTT messages in the log - 2024-04-10 19:42:26 - DEBUG: Publishing to texecom2mqtt/zone/landing_pir: {"name":"Landing PIR","number":16,"areas":["A"],"status":0,"type":"Guard"}

But still I only see 6 of the 11 sensors created as part of the discovery in HA.

Zone 10: Garage Door (Type: Guard; Areas: A)
Zone 11: Front Room Patio Door (Type: Guard; Areas: A)
Zone 12: Family Room Patio Door (Type: Guard; Areas: A)
Zone 13: Back Door (Type: Guard; Areas: A)
Zone 14: Family Room PIR (Type: Guard; Areas: A)
Zone 15: Garage PIR (Type: Guard; Areas: A)

Any Ideas?

I don't know sorry, I was simply a victim of an earlier bug.

This project seems abandoned.

ah thanks, appreciate the response.. Ill get to the bottom of this :0)