Somfy Home Alarm

Hi @asetGem ,

Since the newest versions this add on is broken for me. Could you advice how to set it up?
I have mosquitto broker running with enable discovery flagged. I keep getting permission denied with the add on even though I have set the same creds which I use with the app.

Hi!

Here is the configuration I am using :

somfy_protect:
  username: '!secret somfy_username'
  password: '!secret somfy_mdp'
  sites:
    - Appart # How you called your site in the app
homeassistant_config:
  code: false # or yes if you want to require a code to arm/disarm
  code_arm_required: false
  code_disarm_required: false
mqtt:
  host: core-mosquitto
  port: 1883
  ssl: false
  username: '!secret mqtt_un'
  password: '!secret mqtt_pwd'
  client-id: somfy-protect
  topic_prefix: somfyProtect2mqtt
  ha_discover_prefix: homeassistant
delay_site: '10'
delay_device: '60'
manual_snapshot: false
debug: false  

Are you sure you specified the login and password of your Mosquito broker?
Could you put debug=true in your configuration and send the log? It would be easier to see what is happening.

Hi @asetGem ,

If I follow your config I get the following log:

s6-rc: info: service legacy-services successfully started
[00:49:59] INFO: Generating config.yaml from options.json
[00:49:59] INFO: Configuration :
[00:49:59] INFO: # Generated by homeassistant, do not edit!
# Edit configuration only at the Add-on configuration tab!
debug: true
delay_device: 60
delay_site: 10
homeassistant_config:
  code: <code>
  code_arm_required: false
  code_disarm_required: false
manual_snapshot: false
mqtt:
  client-id: somfy-protect
  ha_discover_prefix: homeassistant
  host: core-mosquitto
  password: <its password which is a very long string>
  port: 1883
  ssl: false
  topic_prefix: somfyProtect2mqtt
  username: homeassistant
somfy_protect:
  password: <pw>
  sites:
    - <sitename>
  username: <uname>
curl: (7) Couldn't connect to server
[00:49:59] ERROR: Something went wrong contacting the API
[00:49:59] INFO: Image build
[00:49:59] INFO: starting original stuff...
2022-07-03 00:49:59,720 [INFO] [__main__:55] Starting SomfyProtect2Mqtt 0.2.1
2022-07-03 00:49:59,721 [INFO] [root:43] Reading config file /usr/bin/SomfyProtect2MQTT/somfyProtect2Mqtt/config/config.yaml
2022-07-03 00:49:59,724 [INFO] [root:114] Init SSO
2022-07-03 00:49:59,724 [INFO] [somfy_protect.sso:79] Requesting Token
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "/usr/lib/python3.9/site-packages/urllib3/util/connection.py", line 73, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/lib/python3.9/socket.py", line 954, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
PermissionError: [Errno 13] Permission denied
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3.9/site-packages/urllib3/connectionpool.py", line 382, in _make_request
    self._validate_conn(conn)
  File "/usr/lib/python3.9/site-packages/urllib3/connectionpool.py", line 1010, in _validate_conn
    conn.connect()
  File "/usr/lib/python3.9/site-packages/urllib3/connection.py", line 358, in connect
    conn = self._new_conn()
  File "/usr/lib/python3.9/site-packages/urllib3/connection.py", line 186, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7fca05304b50>: Failed to establish a new connection: [Errno 13] Permission denied
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/lib/python3.9/site-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3.9/site-packages/urllib3/util/retry.py", line 574, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='sso.myfox.io', port=443): Max retries exceeded with url: /oauth/oauth/v2/token (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fca05304b50>: Failed to establish a new connection: [Errno 13] Permission denied'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/bin/SomfyProtect2MQTT/somfyProtect2Mqtt/main.py", line 59, in <module>
    SSO = init_sso(config=CONFIG)
  File "/usr/bin/SomfyProtect2MQTT/somfyProtect2Mqtt/somfy_protect/sso/__init__.py", line 122, in init_sso
    token = sso.request_token()
  File "/usr/bin/SomfyProtect2MQTT/somfyProtect2Mqtt/somfy_protect/sso/__init__.py", line 80, in request_token
    return self._oauth.fetch_token(
  File "/usr/lib/python3.9/site-packages/requests_oauthlib/oauth2_session.py", line 341, in fetch_token
    r = self.request(
  File "/usr/lib/python3.9/site-packages/requests_oauthlib/oauth2_session.py", line 521, in request
    return super(OAuth2Session, self).request(
  File "/usr/lib/python3.9/site-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3.9/site-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3.9/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='sso.myfox.io', port=443): Max retries exceeded with url: /oauth/oauth/v2/token (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fca05304b50>: Failed to establish a new connection: [Errno 13] Permission denied'))
[22:49:59] WARNING: Halt add-on
s6-rc: info: service legacy-services: stopping
[22:49:59] INFO: Service restart after closing
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped

The strange thing is, when I run the docker container instead of the HA plugin, I do get it to work but only in 1 direction: I can see the status of the alarm_panel but cannot control it.
For that I have to run like so: docker run -v /home/rakimac/somfy:/usr/src/SomfyProtect2MQTT/somfyProtect2Mqtt/config treynaer/somfyprotect2mqtt
with config:

somfy_protect:
  username: <uname>
  password: <pw>
  sites:
    - <sitename>
homeassistant_config:
  code: <code>
  code_arm_required: false
  code_disarm_required: false
mqtt:
  host: 192.168.xx.xxx (internal ip of ha)
  port: 1882 (had to use a different port for this)
  ssl: false
  username: <user created for mqtt>
  password: <its pw>
  client-id: somfy-protect
  topic_prefix: somfyProtect2mqtt
  ha_discover_prefix: homeassistant
delay_site: 10
delay_device: 60
manual_snapshot: false
debug: true

So I’m a bit lost here…

Hi! Sorry, I did not have the notification of your reply!
Try to put your home assistant IP instead of “core-mosquito” in the configuration.

Also, just to be sure we are talking about the same thing, for me, the broker is Mosquito broker (from official HA add-ons), and its config is:

logins:
  - username: '!secret mqtt_u'
    password: '!secret mqtt_p'
require_certificate: false
certfile: fullchain.pem
keyfile: privkey.pem
customize:
  active: false
  folder: mosquitto

In the somfyprotect2mqtt conf, I am using the same mqtt_u and mqtt_p in the mqtt section:

mqtt:
  host: 192.168.xxx.xx
  port: 1883
  ssl: false
  username: '!secret mqtt_u'
  password: '!secret mqtt_p'
  client-id: somfy-protect
  topic_prefix: somfyProtect2mqtt
  ha_discover_prefix: homeassistant

Hi!

Thanks for your reply. Indeed, I was speaking about the somfy badge, so it is dedicated to the alarm, and I don’t think it can be connected by bluetooth with any other gateway than the somfy link.
So, I will try to use something else!

Also, I just realized that I don’t know how to detect that the alarm is triggered. I triggered it on purpose just to see which state it would be in HA, but it stayed to “armed_away”. Is there a way to handle the “triggered” state?

Thanks

@asetGem Sorry, same story here, didnt get notified when you responded.

Today my docker treynaer/somfyprotect2mqtt stopped working (actions on my side don’t update my somfy alarm system, whilst I do get the current status)

So today I tried your plugin once more with version 0.2.4.

somfy_protect:
  username: [email protected]
  password: mypw
  sites:
    - HKFortytwo
  require_certificate: false
  certfile: fullchain.pem
  keyfile: privkey.pem
  customize:
    active: false
    folder: mosquitto
homeassistant_config:
  code: 5
  code_arm_required: false
  code_disarm_required: false
mqtt:
  host: 192.168.xxx.yyy
  port: "1882"
  ssl: false
  username: <my_mqtt_user>
  password: <my_mqtt_pw>
  client-id: somfy-protect
  topic_prefix: somfyProtect2mqtt
  ha_discover_prefix: homeassistant
delay_site: 10
delay_device: "60"
manual_snapshot: false
debug: true

But I still get the same issue as above.
Am I missing something? Maybe I need an additional plugin too?

Yes!! HA automatically discovered my Somfy hub and sub devices in Mosquito! @Minims you are a hero.

My question now is, can I use the motion sensor and door sensor to turn on my hall lamp (while alarm is not active?)

Just looking for a ‘yes this is possible’, I’m very new to this and I want to make sure I’m not on an impossible pathway.

Hello,
you can’t use the motion sensor, because we don’t have the information if the alarm is not active.
About Intellitag, you can check the motion entity on intellitag, but it won’t be reliable if the alarm is off.

Aah got it, thanks for your reply!!

Does Anyone know how to integrate video changing RTMP/RTMPS url/flux in HA ? Thanks