Sector Alarm

Hello @mgejke, thanks for your reply.

I am running a Docker image on Synology. Just bashed into the docker image and found:

root@NAS:/usr/src/app# python --version
Python 3.6.3

So that should be fine then?

Forgot to answer HA version:

Home Assistant
0.56.1

Edit; upgraded to 0.57.2 now, still the same error.

Edit #2

/usr/src/app/homeassistant/helpers/entity.py:307: RuntimeWarning: coroutine 'Sec
torAlarmPanel.async_update' was never awaited                                   
  yield from self.async_update()                                                
2017-11-07 11:55:43 ERROR (MainThread) [homeassistant.helpers.entity] Update for
 alarm_control_panel.sector_alarm_01234567 fails                                
Traceback (most recent call last):                                              
  File "/usr/src/app/homeassistant/helpers/entity.py", line 204, in async_update
_ha_state                                                                       
    yield from self.async_device_update()                                       
  File "/usr/src/app/homeassistant/helpers/entity.py", line 307, in async_device
_update                                                                         
    yield from self.async_update()                                              
TypeError: cannot 'yield from' a coroutine object in a non-coroutine generator 

Got this error from the console log. That first part was not in there in the log from the UI I think. Not sure it gives more meaning?

@corvy
Ah, that’s actually a newer HA version than I’m using.
From my limited knowledge it looks like a bug in HA… I’ll have to check some more tonight.

However, you can get around it by changing:

    async def async_update(self):
        update = self._hub.update()
        if update:
            await update

to:

    @asyncio.coroutine
    def async_update(self):
        update = self._hub.update()
        if update:
            yield from update

In the files in sensors/ and alarm_control_panel/

1 Like

@mgejke
Thanks Martin, that really worked to kill off the errors in the log. :smiley:

Still I get this status on the sensors in <>:

Entity:
alarm_control_panel.sector_alarm_01234567

State:
unknown

Attributes:
code_format: ^\d{4,6}$
changed_by:
friendly_name: Sector Alarm 01234567

Is there some logging option to find out why it cannot pull the status from Sector? It seems to log in fine since if I put an ID that is wrong then it does not work at all. Something is still fishy…

The errors in the log actually seems to be a HA bug… But I’ve changed to the working code in the repo.

I don’t know why you don’t get any status for the alarm, I’ve added some debug output as well. So update from the repo and make sure you have the logger-component in your configuration and let me now what it says(might be that you want to anonymize it a bit… )

Thanks @mgejke

Seems I f#%#%ed up my HA install by upgrading to 0.57.2 so I need to find a way to fix that first. Been fighting all night with it without moving forward at all. As soon as I find the solution I will pop right back to this topic.

If you have any ideas or time to have a look my issue is here:
https://community.home-assistant.io/t/unable-to-log-into-webpage-after-upgrade/31921

Not sure, but does the upgrade maybe change my config files somehow? Sorry for the off-topic. Will go sleep a bit and hope someone found some kind of way forward!

Thanks for all your great work :smiley:

Hello again @mgejke

Finally back up and running … :smiley: :smiley:

I have now git’ed a new copy of the plugin and enabled debug logging. I did a grep for sector_alarm in the log and replacted the alarm ID. The result is here: https://pastebin.com/XEPqXADG

I cannot see anything useful in here myself, it all looks good to my eyes.

Hello, stop the press, I just checked with Sector and it seems they have issues with my central, so this is probably not the plugins fault at all! :smiley:

Great news, Sector fixed it :slight_smile:

Thank you for your efforts!

Alright… Odd!
I checked your sector log and you have entries in it called “mainsrestore” and “mains” that I haven’t seen before(instead of just “armed”, “disarmed” etc). I’ll make a fix so that it handles that case anyway…
Did the say anything about what was wrong?
Did you tell them why you were asking? I’m not sure what their opinion about plugins like this is :slight_smile:

@mgejke I just tried to run the Sector app on my phone at it could not get status from my central at home so I quickly gathered that this was not a HA issue but an issue with the alarm system itself. When I called Sector I complained about their app, no info about HA at all :roll_eyes: Good secrets are best kept well hidden imho :smiley: :smiley:

The stated that my central was “offline”. Whatever that means. The central is GSM based. What they did I do not know but suddenly it worked again. The probably booted it or something similar.

Mains and mainsrestore might be if the central looses power from the mains in the house. I know that the system puts out alarms on both loosing power, low battery on devices and more. This data is relayed to Sector and not to the user/app or similar. Not sure if the log entries you see could be related?

Just tried this on Hass.io with 0.59.2 and works fine so far.
Does not need any hacks or add-ons…

Instructions for hass.io:

  1. Download hass-sectoralarm and asyncsector
  2. Create a new folder in hass io config folder called custom_components
  3. Put the content from hass-sectoralarm and the folder asyncsector from asyncsector in to the newly created folder.
  4. Edit configuration.yaml and add the settings… here is an example
    sector_alarm:
      email: [email protected]
      password: 12345678
      alarm_id: 12345678
      code: 00000
      thermometers: true
      alarm_panel: true

This is how the custom_components folder look:
hass-sector

2 Likes

Great that it works!
However, you shouldn’t have to download asyncsector, home assistant should handle that dependency by itself.

I have tried this too and it works! I have been looking for this functionality a long time, thanks!
However, I can confirm that asyncsector folder needs to be in custom_components on a hass.io install.

One questions though:
How do I show the attributes last_changed and changed_by in the UI?
I have added the following to my customize.yaml, but nothing shows.

  show_last_changed: true
  show_changed_by: true

Ok, my bad. Forgot state-card-custom-ui. But now I am trying to show both last_changed and changed_by like this:

  custom_ui_state_card: state-card-custom-ui
  extra_data_template: ${attributes.last_changed} av ${attributes.changed_by}

But it show “undefined by [username]”, so last_changed doesn’t work.

Haven’t actually tried hass.io, I just assumed it would resolve dependencies like a plain HA-install would, but if you say asyncsector-folder is needed I’ll trust you :slight_smile:

There is no last_changed attribute on the alarm component. Where did you get that from? I guess it could be added…

Hi!
@mgejke great addon to HA!

Must admit that I’m a bit new to this but appreciate if any help can be provided.
I’ve added the components according to @endor instructions but get the following error:

Error during setup of component sector_alarm
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/homeassistant/setup.py”, line 190, in _async_setup_component
result = yield from component.async_setup(hass, processed_config)
File “/config/custom_components/sector_alarm.py”, line 83, in async_setup
CONF_CODE: config[DOMAIN][CONF_CODE]
KeyError: ‘code’

I’m running Hassio, 0.60.1 and added asyncsector to the custom_components folder as well.

Any thoughts on how to get this fixed?

Thanks!

Have you entered the configuration.yaml data. Seems like something could be wrong with that and specifically the content or lack of code: parameter?

@endor Thanks, now it works! As it was set as “optional” I pressumed that I could leave it out completely.

Hmm yes, that is strange.
You could enter 0000 as code if you don’t plan to use homeassistant for arming or disarming your alarm, that way you will never expose your pin in a text file.