Configuração MQTT/Zigbee

Boa tarde a todos,

Ganhei coragem e comecei a dar os primeiros passos (aviso que sou noob nestas coisas).
Material:
-Raspberry;
-Pen c2531( user fez-me a gentileza de vender flashada);

  • sensor aqara humidity
    Comecei por instalar o hassio também o MQTT, Zigbee mas acho que tenho erros não entendo onde por isso peço a vossa ajuda.
    Para integrar o sensor aqara só preciso do Zigbee correto?

Config Zigbee:

{
“data_path”: “/share/zigbee2mqtt”,
“devices”: “devices.yaml”,
“groups”: “groups.yaml”,
“homeassistant”: true,
“permit_join”: false,
“mqtt”: {
“base_topic”: “zigbee2mqtt”,
“server”: “mqtt://192.168.1.48:1883”,
“user”: “”,
“password”: “”
},
“serial”: {
“port”: “/dev/ttyACM0”
},
“advanced”: {
“pan_id”: 6754,
“channel”: 11,
“network_key”: [
1,
3,
5,
7,
9,
11,
13,
15,
0,
2,
4,
6,
8,
10,
12,
13
],
“availability_blacklist”: []
},
“ban”: [],
“whitelist”: [],
“queue”: {},
“socat”: {
“enabled”: false,
“master”: “pty,raw,echo=0,link=/dev/ttyZ2M,mode=777”,
“slave”: “tcp-listen:8485,keepalive,nodelay,reuseaddr,keepidle=1,keepintvl=1,keepcnt=5”,
“restartdelay”: 1,
“initialdelay”: 1,
“options”: “-d -d”,
“log”: false
}
}

MQTT:
( não entendo quando quero alterar a pass e user não faz save)

{
“logins”: [],
“anonymous”: false,
“customize”: {
“active”: false,
“folder”: “mosquitto”
},
“certfile”: “fullchain.pem”,
“keyfile”: “privkey.pem”,
“require_certificate”: false
}

Por isso pedia a vossa ajuda

obrigado a todos

@imrr quando publicares código ou logs deves sublinhar o texto que queres transformar em código e clicar no icone </>. Deverá existir um espaço antes e outro depois do bloco de código para que funcione correctamente. O código em Yaml é muito sensível aos espaçamentos e sem o código devidamente formatado não te poderemos ajudar. E nos logs há pormenores que só devidamente formatados se conseguem ver. Além disso, existem regras no fórum que devem ser cumpridas e que podes ler nos nossos Termos do Serviço/Regras e na FAQ .

@j_assuncao obrigado
Bem vou tentar colocar aqui as config´s corretamente:

CONFIG MQTT

{
  "logins": [],
  "anonymous": false,
  "customize": {
    "active": false,
    "folder": "mosquitto"
  },
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem",
  "require_certificate": false
}

CONFIG Zigbee

{
  "data_path": "/share/zigbee2mqtt",
  "devices": "devices.yaml",
  "groups": "groups.yaml",
  "homeassistant": true,
  "permit_join": false,
  "mqtt": {
    "base_topic": "zigbee2mqtt",
    "server": "mqtt://192.168.1.48:1883",
    "user": "",
    "password": ""
  },
  "serial": {
    "port": "/dev/ttyACM0"
  },
  "advanced": {
    "pan_id": 6754,
    "channel": 11,
    "network_key": [
      1,
      3,
      5,
      7,
      9,
      11,
      13,
      15,
      0,
      2,
      4,
      6,
      8,
      10,
      12,
      13
    ],
    "availability_blacklist": []
  },
  "ban": [],
  "whitelist": [],
  "queue": {},
  "socat": {
    "enabled": false,
    "master": "pty,raw,echo=0,link=/dev/ttyZ2M,mode=777",
    "slave": "tcp-listen:8485,keepalive,nodelay,reuseaddr,keepidle=1,keepintvl=1,keepcnt=5",
    "restartdelay": 1,
    "initialdelay": 1,
    "options": "-d -d",
    "log": false
  }
}

YAML

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
#   base_url: example.duckdns.org:8123

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml

########### mqtt ##########
mqtt:
    broker: 192.168.1.48:1883
    
######### zigbee ########
input_boolean:
  zigbee_permit_join:
    name: Allow devices to join
    initial: off
    icon: mdi:cellphone-wireless

timer:
  zigbee_permit_join:
    name: Time remaining
    duration: 600 # Updated this to the number of seconds you wish

sensor:
  - platform: mqtt
    name: Bridge state
    state_topic: "zigbee2mqtt/bridge/state"
    icon: mdi:router-wireless

group:
  zigbee_group:
    name: Zigbee
    entities:
      - input_boolean.zigbee_permit_join
      - timer.zigbee_permit_join
      - sensor.bridge_state

automation:
  - id: enable_zigbee_join
    alias: Enable Zigbee joining
    hide_entity: true
    trigger:
      platform: state
      entity_id: input_boolean.zigbee_permit_join
      to: 'on'
    action:
    - service: mqtt.publish
      data:
        topic: zigbee2mqtt/bridge/config/permit_join
        payload: 'true'
    - service: timer.start
      data:
        entity_id: timer.zigbee_permit_join
  - id: disable_zigbee_join
    alias: Disable Zigbee joining
    trigger:
    - entity_id: input_boolean.zigbee_permit_join
      platform: state
      to: 'off'
    action:
    - data:
        payload: 'false'
        topic: zigbee2mqtt/bridge/config/permit_join
      service: mqtt.publish
    - data:
        entity_id: timer.zigbee_permit_join
      service: timer.cancel
    hide_entity: true
  - id: disable_zigbee_join_timer
    alias: Disable Zigbee joining by timer
    hide_entity: true
    trigger:
    - platform: event
      event_type: timer.finished
      event_data:
        entity_id: timer.zigbee_permit_join
    action:
    - service: mqtt.publish
      data:
        topic: zigbee2mqtt/bridge/config/permit_join
        payload: 'false'
    - service: input_boolean.turn_off
      data:
        entity_id: input_boolean.zigbee_permit_join
  

Espero que tenha feito corretamente.

E quando tentas fazer save do user e pass como estás a fazer?

1º stop
2ºaltero a configuração

{
    "logins": [
    {
      "username": "mosquitto",
      "password": "mosquitto"
    }
  ],
  "anonymous": false,
  "customize": {
    "active": false,
    "folder": "mosquitto"
  },
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem",
  "require_certificate": false
}

3º save
4ºStart

Pode ser um problema de indentação, tenta assim:

{
  "logins": [
    {
      "username": "mosquitto",
      "password": "mosquitto"
    }
  ],
  "anonymous": false,
  "customize": {
    "active": false,
    "folder": "mosquitto"
  },
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem",
  "require_certificate": false
}

P.S.: Desaconselho o uso desses dados de login, tenta usar o mesmo que tens para o HA.

Perfeito consegui,

LOG

[20:59:19] INFO: Setup mosquitto configuration
[20:59:19] WARNING: SSL not enabled - No valid certs found!
[20:59:19] INFO: Found local users inside config
[20:59:23] INFO: Initialize Hass.io Add-on services
[20:59:23] INFO: Initialize Home Assistant discovery
[20:59:23] INFO: Start Mosquitto daemon
1575752363: mosquitto version 1.6.3 starting
1575752363: Config loaded from /etc/mosquitto.conf.
1575752363: Loading plugin: /usr/share/mosquitto/auth-plug.so
1575752363: |-- *** auth-plug: startup
1575752363:  ├── Username/password checking enabled.
1575752363:  ├── TLS-PSK checking enabled.
1575752363:  └── Extended authentication not enabled.
1575752363: Opening ipv4 listen socket on port 1883.
1575752363: Opening ipv6 listen socket on port 1883.
1575752363: Opening websockets listen socket on port 1884.
1575752363: Warning: Mosquitto should not be run as root/administrator.
1575752406: New connection from 172.30.32.1 on port 1883.
[INFO] found mosquitto on local database
1575752410: New client connected from 172.30.32.1 as mqttjs_bda2f987 (p2, c1, k60, u'mosquitto').

Penso que se encontra a trabalhar corretamente ?

Sim mas não esqueças que depois tens de colocar esses dados de user e pass em todos os dispositivos que se liguem por MQTT.

Desde já muito obrigado @j_assuncao pela ajuda.

Próximo passo passa por Zigbee que penso estar a funcionar:

LOG

./run.sh: line 16: [Info] Configuration backup found in /share/zigbee2mqtt/.configuration.yaml.bk. Skipping config backup.: No such file or directory
[Info] Socat is DISABLED and not started
2019-12-07T20:59:45: PM2 log: Launching in no daemon mode
2019-12-07T20:59:46: PM2 log: App [npm:0] starting in -fork mode-
2019-12-07T20:59:46: PM2 log: App [npm:0] online
> zigbee2mqtt@1.7.1 start /zigbee2mqtt-1.7.1
> node index.js
zigbee2mqtt:info  2019-12-07T21:00:01: Logging to directory: '/share/zigbee2mqtt/log/2019-12-07.20-59-58'
zigbee2mqtt:info  2019-12-07T21:00:02: Starting zigbee2mqtt version 1.7.1 (commit #unknown)
zigbee2mqtt:info  2019-12-07T21:00:02: Starting zigbee-herdsman...
zigbee2mqtt:info  2019-12-07T21:00:05: zigbee-herdsman started
zigbee2mqtt:info  2019-12-07T21:00:05: Coordinator firmware version: '{"type":"zStack12","meta":{"transportrev":2,"product":0,"majorrel":2,"minorrel":6,"maintrel":3,"revision":20190223}}'
zigbee2mqtt:info  2019-12-07T21:00:05: Currently 0 devices are joined:
zigbee2mqtt:info  2019-12-07T21:00:05: Zigbee: disabling joining new devices.
zigbee2mqtt:info  2019-12-07T21:00:05: Connecting to MQTT server at mqtt://192.168.1.48
zigbee2mqtt:info  2019-12-07T21:00:10: Connected to MQTT server
zigbee2mqtt:info  2019-12-07T21:00:10: MQTT publish: topic 'zigbee2mqtt/bridge/state', payload 'online'
zigbee2mqtt:info  2019-12-07T21:00:11: MQTT publish: topic 'zigbee2mqtt/bridge/config', payload '{"version":"1.7.1","commit":"unknown","coordinator":{"type":"zStack12","meta":{"transportrev":2,"product":0,"majorrel":2,"minorrel":6,"maintrel":3,"revision":20190223}},"log_level":"info","permit_join":false}'

Tenho duvidas para os passos seguintes tenho de ir a integrações para adcionar dispositivos?
No ficheiro YAML não devo alterar alguma coisa para os sensores aqara?

obg

Essas questões já saem fora do tema deste tópico. Agora tens de ir ler a wiki do Zigbee2MQTT para saberes como fazer para adicionar dispositivos. Se continuares com duvidas, abre um novo tópico caso os já existentes não tenham as informações que necessitas.

Muito obrigado pela ajuda


Copyright © 2017-2020. Todos os direitos reservados
CPHA.pt - info@cpha.pt


FAQ | Termos de Serviço/Regras | Política de Privacidade