dchesterton / texecom2mqtt-hassio

Home Assistant add-on. Connect to Texecom Premier Elite alarm panels and publish updates to MQTT. Supports arming/disarming as well as zone updates and alarm events.
https://hub.docker.com/r/dchesterton/texecom2mqtt
MIT License
50 stars 9 forks source link

Container won't start on Supervisor 2021.02.5 #10

Closed RogerSelwyn closed 3 years ago

RogerSelwyn commented 3 years ago

The texecom2mqtt add-on will no longer start. Only change made was to upgrade Supervisor to 2021-02-5 and reboot server.

The following error is shown in the Texecom2mqtt log:

(node:6) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'port' of undefined
    at setDefaults (/snapshot/app/dist/config.js:18:96)
    at Object.loadConfig (/snapshot/app/dist/config.js:65:16)
    at /snapshot/app/dist/index.js:18:29
    at Generator.next (<anonymous>)
    at /snapshot/app/dist/index.js:8:71
    at new Promise (<anonymous>)
    at /snapshot/app/dist/index.js:4:12
    at /snapshot/app/dist/index.js:17:8
    at Object.<anonymous> (/snapshot/app/dist/index.js:56:4)
    at Module._compile (pkg/prelude/bootstrap.js:1320:22)
(node:6) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:6) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
The following errors are shown in my supervisor log:
21-02-08 12:28:55 WARNING (MainThread) [supervisor.addons.options] Unknown options texecom
21-02-08 12:28:55 WARNING (MainThread) [supervisor.addons.options] Unknown options mqtt
21-02-08 12:28:55 WARNING (MainThread) [supervisor.addons.options] Unknown options homeassistant
21-02-08 12:28:55 WARNING (MainThread) [supervisor.addons.options] Unknown options log
21-02-08 12:28:55 WARNING (MainThread) [supervisor.addons.options] Unknown options texecom
21-02-08 12:28:55 WARNING (MainThread) [supervisor.addons.options] Unknown options mqtt
21-02-08 12:28:55 WARNING (MainThread) [supervisor.addons.options] Unknown options homeassistant
21-02-08 12:28:55 WARNING (MainThread) [supervisor.addons.options] Unknown options log
21-02-08 12:28:56 INFO (SyncWorker_3) [supervisor.docker.addon] Starting Docker add-on dchesterton/texecom2mqtt with version None

Environment is as below:

System Health

version core-2021.2.1
installation_type Home Assistant Supervised
dev false
hassio true
docker true
virtualenv false
python_version 3.8.7
os_name Linux
os_version 5.4.0-65-generic
arch x86_64
timezone Europe/London
Home Assistant Community Store GitHub API | ok -- | -- Github API Calls Remaining | 4958 Installed Version | 1.11.0 Stage | running Available Repositories | 710 Installed Repositories | 9
Home Assistant Supervisor host_os | Ubuntu 20.04.2 LTS -- | -- update_channel | stable supervisor_version | supervisor-2021.02.5 docker_version | 19.03.13 disk_total | 31.4 GB disk_used | 21.5 GB healthy | true supported | failed to load: Unsupported supervisor_api | ok version_api | ok installed_addons | Samba share (9.3.0), Node-RED (8.1.0), SSH & Web Terminal (8.0.0), File editor (5.2.0), Dropbox Sync (1.3.0), Mosquitto broker (5.1), AdGuard Home (3.0.0), Apache2 (1.7.2), MariaDB (2.2.1), OpenZWave (0.9.0), Nginx Proxy Manager (0.9.0), FTP (4.0.0), texecom2mqtt (latest), Ring Devices (4.3.0), Grafana (6.1.0)
Lovelace dashboards | 2 -- | -- resources | 5 views | 9 mode | storage
RogerSelwyn commented 3 years ago

Could it be because there is no schema specified in config.json?

dchesterton commented 3 years ago

I'm looking into this. It looks like there must have been a change in Supervisor around how config is handled. Supervisor is supposed to skip validation if schema is false but it could be a culprit.

brinzlee commented 3 years ago

I have the same issue too, happened after upgrading to Supervisor 2021.02.05 thanks @dchesterton for looking at this...

madmic1314 commented 3 years ago

Appears this is a change that is was with the latest Supervisor and is mandatory: https://github.com/home-assistant/developers.home-assistant/pull/799

Thrifty666 commented 3 years ago

I'm having the same issue. The integration has stopped working for me since the latest home assistant update.

dchesterton commented 3 years ago

Yeah looks like schema has become mandatory with no warning or deprecation and broken quite a few add-ons 🙄 I'll add a schema to the add-on

mrwee commented 3 years ago

Same problem here. @dchesterton Thank you for your prompt reaction 🥇

ManicGTI commented 3 years ago

Newly installed and same issue here.

dchesterton commented 3 years ago

I've changed schema to an empty object. I think it'll fix the issue and it appears to work locally, but I don't personally run the app via Supervisor myself. If a few people could pull the latest version and see if it fixes the issue that'd be much appreciated.

Thrifty666 commented 3 years ago

@dchesterton thanks for your response. I've only just got into home assistant and your add-on is very much appreciated, i've based quite a few automations on alarm sensor states thanks for all the hard work you've done. For some reason when the alarm is set it only says 'pending' in home assistant but I've just worked out how to use the the mqtt messages instead so it all works brilliantly for what I need. Thanks again. Paul.

dchesterton commented 3 years ago

@Thrifty666 Hi Paul, I'm glad it's useful 🙂 can you post your config? It sounds like you haven't got your Home Assistant mapping set up quite right

mrwee commented 3 years ago

@dchesterton Sorry for a possible dumb question, but mine usually updates automatically, how do I do it manually?

Thrifty666 commented 3 years ago

@dchesterton I'm almost positive I haven't done it right as well 🤣but it all works as I need it for now. I've for the following for the add-on log at the moment...

(node:6) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'port' of undefined at setDefaults (/snapshot/app/dist/config.js:18:96) at Object.loadConfig (/snapshot/app/dist/config.js:65:16) at /snapshot/app/dist/index.js:18:29 at Generator.next () at /snapshot/app/dist/index.js:8:71 at new Promise () at /snapshot/app/dist/index.js:4:12 at /snapshot/app/dist/index.js:17:8 at Object. (/snapshot/app/dist/index.js:56:4) at Module._compile (pkg/prelude/bootstrap.js:1320:22) (node:6) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:6) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

dchesterton commented 3 years ago

Sorry for a possible dumb question, but mine usually updates automatically, how do I do it manually?

@mrwee Not dumb at all, I'm not sure myself! I think the easiest way might be to delete and re-add the add-on, just make sure to back-up your config first.

RogerSelwyn commented 3 years ago

I think the easiest way might be to delete and re-add the add-on, just make sure to back-up your config first.

Supervisor didn't show a new version (possibly because your config.json shows 'latest' as the version ?), so I uninstalled/reinstalled and still get the same error. However I can't tell if it is picking up the latest since Supervisor reports:-

21-02-08 20:05:10 INFO (SyncWorker_2) [supervisor.docker.addon] Starting Docker add-on dchesterton/texecom2mqtt with version None

Thrifty666 commented 3 years ago

I uninstalled the add-on then re installed it but I'm still having the same issue. Now because of my lack knowledge on this sort of thing I'm not sure if it's me that's broken it or the add-on still isn't working...🤷🏻‍♂️

garryanderson-net commented 3 years ago

I also install via HA/Supervisor/Add-On Store and also see that no 'new' version is showing. I also uninstalled/reinstalled however i believe what I reinstalled was exactly the same code as i uninstalled as i see exactly the same result as before.

Thanks for your support on this,

RogerSelwyn commented 3 years ago

I've done some playing with schema, the following works, but of course is missing areas and zones. It may also not meet everyones needs since I have only added the attributes I need, so is missing some (e.g. port) and some that I have set may need to be optional (e.g. client_id) which can be achieved by adding a ? to the definition.

  "schema": {
    "texecom": {
      "host": "str",
      "udl_password": "str"
    },
    "mqtt": {
      "host": "str",
      "username": "str",
      "password": "str",
      "client_id": "str",
      "keepalive": "int(0,)?",
      "retain": "bool"
    },
    "homeassistant": {
      "discovery": "bool"
    },
    "log": "int(0,)?"
  },

This allows an install and the add-on to start. What I can't figure out is whether zones and areas can be achieved, since 4/5 layers deep and don't use known key names. HA documentation states that only nested arrays and dictionaries that are 2 deep are supported (well I think that is what it says).

https://developers.home-assistant.io/docs/add-ons/configuration/#options--schema

If I add "zones": {} and "areas": {}, I get the following error in the Supervisor log:

21-02-08 22:08:58 WARNING (MainThread) [supervisor.store.data] Can't read /data/addons/git/72abca22/config.json: expected string or buffer for dictionary value @ data['schema']['homeassistant']['areas']. Got {}
expected string or buffer for dictionary value @ data['schema']['homeassistant']['zones']. Got {}

I'm not sure if the structure can be re-worked to something flatter?

homeassistant:
  ...,
  "areas": [
    {
      "areaname": "str",
      "full_arm": "str",
      "part_arm: "str"
    }
  ],
  "zones": [
    {
      "zonename": "str",
      "device_class": "str",
    }
  ],
dchesterton commented 3 years ago

I realised that I wasn't testing the fix on the latest version of Supervisor 🤦🏻‍♂️ It is still broken unfortunately.

Thanks @RogerSelwyn, I was just looking into solutions for the same problem 😀 this was the reason I didn't create a schema when I first created the add-on.

I'm not sure if the structure can be re-worked to something flatter?

homeassistant:
  ...,
  "areas": [
    {
      "areaname": "str",
      "full_arm": "str",
      "part_arm: "str"
    }
  ],
  "zones": [
    {
      "zonename": "str",
      "device_class": "str",
    }
  ],

Unfortunately this still has the same problem in that it's more than 2 levels deep. Additionally, if I change the config structure now it will break for everyone who has configured the app including those who have installed it outside of Home Assistant OS.

Having said that, quite a few people have had issues with the config structure and on reflection, it is quite complicated. I think I'm going to take a little bit of time to think this through. If I have to make a breaking change, I want to use the opportunity to fix it properly.

Apologies to everyone who this is currently broken for. It's really frustrating that this functionality has been removed with no warning and there's no easy fix.

RogerSelwyn commented 3 years ago

No worries, these things happen. As ha been noted, other addons are having problems as well. I'll look to install via Docker direct, and then revert back when you fix it. Just means I have to pop into portainer if I want to check it is working ok 🙂

madmic1314 commented 3 years ago

Thanks and understand. Would it be possible to release a separate beta version to get it going in HA whilst you work on the perm solution? Thinking docker might be beyond some people's skillset.

Do we know why the HA Devs did this? Seems a poor show without adequate notice - are they aware of the impact this had? Not sure I've got the full story here though.

dchesterton commented 3 years ago

No worries, these things happen. As ha been noted, other addons are having problems as well. I'll look to install via Docker direct, and then revert back when you fix it. Just means I have to pop into portainer if I want to check it is working ok 🙂

Cool 🙂 I personally prefer to keep functionality outside of HA for these exact reasons but I appreciate that a lot of people prefer to have it in one place. By the way, I just realised you created the Sky Q Media Player. I installed it a couple of weeks ago and it's been working really well so thanks for that 👍

Thanks and understand. Would it be possible to release a separate beta version to get it going in HA whilst you work on the perm solution? Thinking docker might be beyond some people's skillset.

Yeah, I completely understand that most people won't want to go down the Docker route - especially for a short term fix - but any beta version will require an update to the main app which I want to avoid at this time. I'd recommend downgrading Supervisor as a short term solution.

Do we know why the HA Devs did this? Seems a poor show without adequate notice - are they aware of the impact this had? Not sure I've got the full story here though.

I'd like to think it's an oversight as thankfully most add-ons can be fixed fairly simply by creating a schema. It's where add-ons have a more complex schema that there's no easy upgrade path. The frigate add-on seems to be in the same quandary: https://github.com/blakeblackshear/frigate/issues/703

mrwee commented 3 years ago

I got this update this morning: image

Updating did not make it work.

B-Hartley commented 3 years ago

How easy is it to rollback the supervisor ?

B-Hartley commented 3 years ago

Frigate seem to have worked around it by using a config file that is outside the add-on. So it can't be configured through the configuration tab, but it does work. Could this be done as a quick and dirty fix ?

madmic1314 commented 3 years ago

How easy is it to rollback the supervisor ?

Don't believe you can as it'll auto-update you to the newest version.

https://github.com/home-assistant/frontend/pull/8361 was merged. When you get this you need to have a backup of your existing addon configuration beforehand else you'll have lost it.

iMiMx commented 3 years ago

How easy is it to rollback the supervisor ?

Don't believe you can as it'll auto-update you to the newest version.

home-assistant/frontend#8361 was merged. When you get this you need to have a backup of your existing addon configuration beforehand else you'll have lost it.

https://community.home-assistant.io/t/how-do-you-rollback-supervisor-version/278757

Rolled back to 04, didnt seem to fix it for me, having a further look.

Then I tried to uninstall this addon and reinstall, but it wouldn't let me because it was in an 'unhealthy' state.

EDIT: Ah, and to clear the unhealthy state I rebooted the (unsupported) install/machine, then on reboot, it auto updates the supervisor.

dchesterton commented 3 years ago

Ah, I wasn't aware Supervisor worked in this way 😔 I'm looking into a solution, I should hopefully have something by tomorrow.

B-Hartley commented 3 years ago

doh ! Guess I'll wait till tomorrow in the hope of a fix, otherwise I'll have to dig out a spare pi and start playing with docker !

RogerSelwyn commented 3 years ago

Ah, I wasn't aware Supervisor worked in this way 😔 I'm looking into a solution, I should hopefully have something by tomorrow.

Seems like the 2021.2.x supervisor have broken multiple things. People are getting UDEV errors, which looks like it is breaking Addons. I'd anticipate new supervisor versions in quick succession.

TomBrien commented 3 years ago

According to home-assistant/supervisor#2540 it looks like the nesting depth limit is actually more of a recommendation than a requirement

dchesterton commented 3 years ago

I've released an update to fix the issue.

It requires a change to your config format unfortunately, but I've taken the opportunity to simplify the config massively which should fix a lot of the pain points with the application.

I've also put in quite a bit of code to validate the config so you should get a nice warning/error telling you what's wrong and how to fix it if your config is not quite right.

The full format is on the Docker page: https://hub.docker.com/r/dchesterton/texecom2mqtt but essentially where you had something like this before:

log: 0

texecom:
  ...
mqtt:
  ...

homeassistant:
  discovery: true
  prefix: "home-assistant"
  areas:
    house:
      name: "House Alarm"
      mapping:
        full_arm: armed_away
        part_arm_1: armed_night
        part_arm_2: armed_home
      options:
        code_arm_required: true
        code_disarm_required: true
        code: 123456
  zones:
    front_door:
      device_class: "motion"
      name: "Living Room Motion Sensor"

It will now be:

log: debug

texecom:
  ...
mqtt:
  ...

homeassistant:
  discovery: true
  prefix: "home-assistant"

zones:
- id: front_door
  name: "Front Room Motion Sensor"
  device_class: "motion"

areas:
- id: house
  name: "House Alarm"
  full_arm: armed_away
  part_arm_1: armed_night
  part_arm_2: armed_home
  code_arm_required: true
  code_disarm_required: true
  code: 123456

Additionally, I've fixed the versioning issue on the add-on store so you should see an update button to easily update to the latest version.

Please let me know if the fix works for you. Sorry for the delay getting it sorted and also for having to change your config but it should improve things going forward.

B-Hartley commented 3 years ago

I'm gettting an error:


404 Client Error for http+docker://localhost/v1.40/images/create?tag=1.0.13&fromImage=dchesterton%2Ftexecom2mqtt: Not Found ("manifest for dchesterton/texecom2mqtt:1.0.13 not found: manifest unknown: manifest unknown")
garryanderson-net commented 3 years ago

Just tried to re-install via the Add-on Store...i get the following in a popup

404 Client Error for http+docker://localhost/v1.40/images/create?tag=v1.0.4&fromImage=dchesterton%2Ftexecom2mqtt: Not Found ("manifest for dchesterton/texecom2mqtt:v1.0.4 not found: manifest unknown: manifest unknown")

perimore commented 3 years ago

Also getting the same on both update then on uninstall/install.

dchesterton commented 3 years ago

Looks like it's still trying to pull older versions of the app. Can you try going to 'Supervisor' - 'Add-on Store', then clicking on the dots icon in the top right and clicking 'Reload'?

It should refresh the repository config and then Supervisor will see the new version.

iMiMx commented 3 years ago

Yes, this fixed it for me - should show version 1.0.14.

Back up and running again, many, many thanks for resolving this.

TomBrien commented 3 years ago

Thanks for this. It's such a shame the config: false bug was fixed in a breaking way without notice

perimore commented 3 years ago

Thanks but getting another error with my config and can't figure it out:

Failed to save addon configuration, not a valid value for dictionary value @ data['options']

but I can't see the dictionary 'options'. It was in the old config but I've completed removed it and started again.

config is:

texecom:
  host: <removed>
  udl_password: '<removed>'

mqtt:
  host: 'mqtt://core-mosquitto:1883'
  username: external_mqtt
  password: <removed>

homeassistant:
  discovery: true

areas:
- id: house
  full_arm: armed_away
  part_arm_1: armed_night
  disarm: disarmed
  code_arm_required: false
- id: garden
  full_arm: armed_away
  part_arm_1: armed_night
  disarm: disarmed
  code_arm_required: false
dchesterton commented 3 years ago

@perimore Try removing disarm: disarmed from your areas. It's not a valid option 🙂 I have to say, the error message from Supervisor when the config is incorrect leaves a lot to be desired considering this is being forced on add-on developers...

perimore commented 3 years ago

worked it out, I had to add the zones definition to the bottom. It's not set to optional as such it seems:

'''zones: []'''

Disarmed is fine and allows me to have a Disarm button permanently in the UI:

Screenshot 2021-02-10 at 19 50 15

To be honest I can't exactly remember why I wanted this. I think it was to stop the alarm when triggering the tamper alarm during install.

dchesterton commented 3 years ago

Ah ok, good spot. There's currently no way to make an array optional with the Supervisor schema 🙄

The disarm option is not supported so I can assure you it's doing nothing 😀 the disarm mapping between HA and the alarm is done automatically and the UI buttons are defined separately in Lovelace. With the stricter config validation the app is doing now, I think you might run into issues with keeping it in there but let me know either way.

perimore commented 3 years ago

Yeh, I've removed disarm from the config and nothing has changed so it's all good! Thanks again

B-Hartley commented 3 years ago

it doesn't seem happy with this.. What have I done?

 texecom:
  host: 192.168.21.1xx
  udl_password: 9999sdfsdf
mqtt:
  host: 'mqtt://192.168.11.1xx:1883'
  username: mqtt_user
  password: BruJas925
homeassistant:
  discovery: true
  prefix: home-assistant
areas:
  - id: '1'
    full_arm: armed_away
    part_arm_1: armed_home
    part_arm_2: armed_night
    code: 9999
    code_arm_required: true
zones: []    
dchesterton commented 3 years ago

Can you try removing the quotes from id: '1' so it's just id: 1?

iMiMx commented 3 years ago

it doesn't seem happy with this.. What have I done?

 texecom:
  host: 192.168.21.1xx
  udl_password: 9999sdfsdf
mqtt:
  host: 'mqtt://192.168.11.1xx:1883'
  username: mqtt_user
  password: BruJas925
homeassistant:
  discovery: true
  prefix: home-assistant
areas:
  - id: '1'
    full_arm: armed_away
    part_arm_1: armed_home
    part_arm_2: armed_night
    code: 9999
    code_arm_required: true
zones: []    

Additional space on texecom, at the beginning? This is mine, working/accepted:

texecom:
  host: x.x.x.x
  udl_password: 'xxxxxx'
mqtt:
  host: 'mqtt://core-mosquitto:1883'
  username: texecom2mqtt
  password: xxxxxxxxxxxx
homeassistant:
  discovery: true
areas:
  - id: '1'
    full_arm: armed_away
    part_arm_1: armed_night
zones: []

Although, I do see this in the log:

2021-02-10 19:52:44 - WARNING: Unknown Area ID '1' (expected area number or one of area_a)

Removing the '' around the 1, it then fails to save:

Failed to save addon configuration, not a valid value for dictionary value @ data['options']. Got {'texecom': {'host': 'x.x.x.x', 'udl_password': 'xxxxxx'}, 'mqtt': {'host': 'mqtt://core-mosquitto:1883', 'username': 'texecom2mqtt', 'password': 'xxxxxxx'}, 'homeassistant': {'discovery': True}, 'areas': [{'id': 1, 'full_arm': 'armed_away', 'part_arm_1': 'armed_night'}], 'zones': []}

Based on the below in the logs:

2021-02-10 20:14:45 - INFO: Fetched area 1: Area A

I changed it to the below and the errors disappeared:

texecom:
  host: x.x.x.x
  udl_password: 'xxxxx'
mqtt:
  host: 'mqtt://core-mosquitto:1883'
  username: texecom2mqtt
  password: xxxxxxx
homeassistant:
  discovery: true
areas:
  - id: area_a
    full_arm: armed_away
    part_arm_1: armed_night
zones: []
BarryTheCat commented 3 years ago

Daniel, I love you! All working again.

Seriously though, thank you so much for making the effort and giving the time to sort this out. More so when it wasn't your fault.

garryanderson-net commented 3 years ago

I'm back in action again...took a couple of attempts to get the config right (for some reason trying to add the 'id'line to areas jumped me to the top of the yaml) - i ended up compiling offline and pasting it in.

My config for others references:

texecom:
  host: IP_OF_TEXECOM_ALARM
  port: PORT_OF_TEXECOM_ALARM
  udl_password: 'UDL_PASS'
mqtt:
  host: 'MQTT_IP:MQTT_PORT'
  username: MQTT_USERNAME
  password: MQTT_PASSWORD
homeassistant:
  discovery: true
areas:
  - id: house
    full_arm: armed_away
    part_arm_1: armed_night
  - id: workshop
    full_arm: armed_away
zones: []

Thankyou Daniel for your help, i can now walk in and out of rooms/open doors and the lights tun on automatically (seemed so alien to manually operate light switches!)

B-Hartley commented 3 years ago

Got It working.
validation seems very sensitive. And hit and miss !

brinzlee commented 3 years ago

I can't get mine going...I have looked at my config compared it to yours and everyone elses...but still get the following error everytime when saving the configuration

Failed to save addon configuration, not a valid value for dictionary value @ data['options'].

**** All sorted now...... For those having a similiar issue if you don't define any zones like me, you must put two brackets in for the zones The other setting I had an issue with this time and not in the previous version, I had to put ' ' around the number of my code: , under areas:

my config....with ** to obliterate my settings to help others

texecom:
  host: 192.168.0.***
  udl_password: '****'
  port: 10001
mqtt:
  host: 'mqtt://192.168.0.***:1883'
  username: ****
  password: ****
  client_id: texecom2mqtt
  keepalive: 30
  retain: true
  retain_log: false
homeassistant:
  discovery: true
  prefix: home-assistant
areas:
  - id: house_alarm
    full_arm: armed_away
    part_arm_1: armed_night
    part_arm_2: armed_home
    code: '****'
    code_arm_required: true
    code_disarm_required: true
zones: []
log: info