Erro no MQTT . Dispositivos indisponiveis


(Luis Alves) #3

Desculpa a falta de informação

Aqui vai:

Home Assistant 0.94.1
zigbee2mqtt 1.4.0
Mosquitto broker 4.3

Configuração :

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

Se quiseres mais alguma info diz sff

Obrigado pela ajuda


(Nuno Neves) #4

Não actualizaste o mosquitto por volta dessa altura?
Já experimentaste usar autenticação em vez de usares anonimous?


(Luis Alves) #5

Sobre a actualização, já andei de volta dela mas deixa de reconhecer todos os dispositivos. Segundo o que li tenho de fazer umas alteração nas cofigurações mais ainda não acertei isso a 100%

Sobre usar autenticação sim já testei e é igual


(Jorge Assunção) #6

Falta a configuração do Z2M e do HA.


(Luis Alves) #7
homeassistant:
  # Name of the location where Home Assistant is running
  name: Ecoarium
  # Location required to calculate the time the sun rises and sets
  latitude: 41.1336
  longitude: -8.6174
  # Impacts weather/sunrise data (altitude above sea level in meters)
  elevation: 0
  # metric for Metric, imperial for Imperial
  unit_system: metric
  # Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
  time_zone: Europe/Lisbon
  # Customization file
  customize: !include customize.yaml
  packages: !include_dir_named packages
  
mqtt:
  broker: 127.0.0.1
  port: 1883
  client_id: hassio
  keepalive: 60
  username: !secret username_mqtt
  password: !secret password_mqtt
  discovery: true
  discovery_prefix: homeassistant
  protocol: 3.1.1

#lovelace:
#  mode: yaml

# Show links to resources in log and frontend
#introduction:

# Enables the frontend
frontend:
  javascript_version: auto

# Enables configuration UI
config:

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

# Checks for available updates
# Note: This component will send some information about your system to
# the developers to assist with development of Home Assistant.
# For more information, please see:
# https://home-assistant.io/blog/2016/10/25/explaining-the-updater/
updater:
  # Optional, allows Home Assistant developers to focus on popular components.
  # include_used_components: true

# Discover some devices automatically
discovery:

# Allows you to issue voice commands from the frontend in enabled browsers
conversation:

# Enables support for tracking state changes over time
history:

# View all events in a logbook
logbook:

# Enables a map showing the location of tracked devices
map:

# Track the sun
sun:

# Allow diagnosing system problems
system_health:

# Sensors
sensor:
  # Weather prediction
  - platform: yr

# Text to speech
tts:
  - platform: google_translate
    service_name: google_say

# Cloud
cloud:

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

panel_iframe:
  ide:
    title: IDE
    icon: mdi:code-braces
    url: http://192.168.1.2:8321

  tasmoadmin:
    title: TasmoAdmin
    icon: mdi:lightbulb-on
    url: http://192.168.1.2:9541
    
  influxdb:
    title: InfluxDB
    icon: mdi:chart-areaspline
    url: http://192.168.1.2:8888
    
  grafana:
    title: Grafana
    icon: mdi:chart-timeline
    url: http://192.168.1.2:3000

  # nodered:
  #   title: Node-RED
  #   icon: mdi:sitemap
  #   url: http://192.168.1.156:1880
    
influxdb:
  host: 192.168.1.2
  port: 8086
  database: homeassistant
  username: **********
  password: **********
  max_retries: 3
  default_measurement: state
#  exclude:
#    domains:
#      - media_player
  include:
    entities:
      - sensor.watts_bateria_1
      - sensor.watts_inertes
      - sensor.watts_vivarium
      - device_tracker.luis_alves
      - sensor.consumo_dia_anterior_bateria_1
      - sensor.0x00158d0002ca0298_temperature

device_tracker:
  - platform: ping
    hosts:
      Luis_alves: 192.168.1.112
      Adelino_Santos: 192.168.1.111
    interval_seconds: 10
{
  "data_path": "/share/zigbee2mqtt",
  "homeassistant": true,
  "permit_join": false,
  "mqtt_base_topic": "zigbee2mqtt",
  "mqtt_server": "mqtt://192.168.1.2:1883",
  "serial_port": "/dev/ttyACM0",
  "devices": [],
  "network_key": [],
  "mqtt_user": "!secret username_mqtt",
  "mqtt_pass": "!secret password_mqtt",
  "log_level": "info"
}
{
  "logins": [
    {
      "username": "!secret username_mqtt",
      "password": "!secret password_mqtt"
    }
  ],
  "anonymous": false,
  "customize": {
    "active": false,
    "folder": "mosquitto"
  },
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem"
}

(Jorge Assunção) #8

Assim rapidamente a unica coisa que vejo é que está a usar o endereço do localhost (127.0.0.1) no configuration.yaml e não devias. O correcto será indicar o endereço IP da máquina que corre o broker, neste caso 192.168.1.2.

A configuração, como a estás a usar, parece ser a do broker interno do Hassio e que vai ser descontinuada. A linha protocol: 3.1.1 não é necessária. Aconselhava-te para despistar o problema a testares as seguintes configurações:

No configuration.yaml

#### MQTT
mqtt:
  broker: 192.168.1.2
  port: 1883
  keepalive: 30
  username: !secret mqtt_username
  password: !secret mqtt_password
  birth_message:
    topic: 'hassio/status'
    payload: 'online'
  will_message:
    topic: 'hassio/status'
    payload: 'offline'
  client_id: hassio_client
  discovery: true
  discovery_prefix: homeassistant

Z2M (alteração no mqtt_server)

{
  "data_path": "/share/zigbee2mqtt",
  "homeassistant": true,
  "permit_join": false,
  "mqtt_base_topic": "zigbee2mqtt",
  "mqtt_server": "http://192.168.1.2",
  "serial_port": "/dev/ttyACM0",
  "devices": [],
  "network_key": [],
  "mqtt_user": "!secret username_mqtt",
  "mqtt_pass": "!secret password_mqtt",
  "log_level": "info"
}

Depois diz como correu.

P.S.: Não esqueçer de fazer um reboot à máquina na totalidade e não apenas ao Hassio!


(Luis Alves) #9

Bom dia
Os dispositivos continuam a ficar indisponiveis de vez em quando
Tenho este log no mqtt

1560415631: New client connected from 192.168.1.147 as DVES_9218B4 (c1, k10, u'chefmoisas').
1560415669: Socket error on client DVES_2C76ED, disconnecting.
1560415669: New connection from 192.168.1.195 on port 1883.
[INFO] found chefmoisas on Home Assistant
1560415671: New client connected from 192.168.1.195 as DVES_2C76ED (c1, k10, u'chefmoisas').
1560415671: Client DVES_EB047B has exceeded timeout, disconnecting.
1560415671: Socket error on client DVES_EB047B, disconnecting.
1560415673: New connection from 192.168.1.111 on port 1883.
[INFO] found chefmoisas on Home Assistant
1560415676: New client connected from 192.168.1.111 as DVES_EB047B (c1, k10, u'chefmoisas').
1560415695: Socket error on client DVES_6AC412, disconnecting.
1560415696: New connection from 192.168.1.146 on port 1883.
[INFO] found chefmoisas on Home Assistant
1560415698: New client connected from 192.168.1.146 as DVES_6AC412 (c1, k10, u'chefmoisas').
1560415698: Socket error on client DVES_9218B4, disconnecting.
1560415703: Socket error on client DVES_938B73, disconnecting.
1560415707: New connection from 192.168.1.147 on port 1883.
[INFO] found chefmoisas on Home Assistant
1560415709: New client connected from 192.168.1.147 as DVES_9218B4 (c1, k10, u'chefmoisas').
1560415709: Socket error on client DVES_457F27, disconnecting.
1560415709: New connection from 192.168.1.125 on port 1883.
[INFO] found chefmoisas on Home Assistant
1560415711: New client connected from 192.168.1.125 as DVES_457F27 (c1, k10, u'chefmoisas').
1560415715: New connection from 192.168.1.109 on port 1883.
[INFO] found chefmoisas on Home Assistant
1560415717: New client connected from 192.168.1.109 as DVES_938B73 (c1, k10, u'chefmoisas').
1560415749: Client DVES_51BF47 has exceeded timeout, disconnecting.
1560415749: Socket error on client DVES_51BF47, disconnecting.
1560415750: New connection from 192.168.1.192 on port 1883.
[INFO] found chefmoisas on Home Assistant
1560415752: New client connected from 192.168.1.192 as DVES_51BF47 (c1, k10, u'chefmoisas').
1560415754: Socket error on client DVES_02BF0A, disconnecting.
1560415754: New connection from 192.168.1.140 on port 1883.
[INFO] found chefmoisas on Home Assistant
1560415756: New client connected from 192.168.1.140 as DVES_02BF0A (c1, k10, u'chefmoisas').
1560415766: Socket error on client DVES_0F51ED, disconnecting.
1560415767: New connection from 192.168.1.193 on port 1883.
[INFO] found chefmoisas on Home Assistant
1560415769: New client connected from 192.168.1.193 as DVES_0F51ED (c1, k10, u'chefmoisas').
1560415796: Socket error on client DVES_9218B4, disconnecting.
1560415797: New connection from 192.168.1.147 on port 1883.
[INFO] found chefmoisas on Home Assistant
1560415799: New client connected from 192.168.1.147 as DVES_9218B4 (c1, k10, u'chefmoisas').
1560415833: Socket error on client DVES_96C131, disconnecting.
1560415833: New connection from 192.168.1.138 on port 1883.
[INFO] found chefmoisas on Home Assistant
1560415835: New client connected from 192.168.1.138 as DVES_96C131 (c1, k10, u'chefmoisas').
1560415835: Saving in-memory database to /data/mosquitto.db.
1560415866: Socket error on client DVES_0F51ED, disconnecting.
1560415866: Socket error on client DVES_02BF0A, disconnecting.
1560415866: New connection from 192.168.1.193 on port 1883.
[INFO] found chefmoisas on Home Assistant
1560415868: New client connected from 192.168.1.193 as DVES_0F51ED (c1, k10, u'chefmoisas').
1560415868: New connection from 192.168.1.140 on port 1883.
[INFO] found chefmoisas on Home Assistant
1560415870: New client connected from 192.168.1.140 as DVES_02BF0A (c1, k10, u'chefmoisas').
1560415870: Socket error on client DVES_02B123, disconnecting.
1560415870: New connection from 192.168.1.174 on port 1883.
[INFO] found chefmoisas on Home Assistant
1560415872: New client connected from 192.168.1.174 as DVES_02B123 (c1, k10, u'chefmoisas').
1560415875: Socket error on client DVES_9218B4, disconnecting.
1560415875: New connection from 192.168.1.147 on port 1883.
[INFO] found chefmoisas on Home Assistant
1560415877: New client connected from 192.168.1.147 as DVES_9218B4 (c1, k10, u'chefmoisas').
1560415886: Socket error on client DVES_51BF47, disconnecting.
1560415887: Socket error on client DVES_6B14F8, disconnecting.
1560415887: New connection from 192.168.1.192 on port 1883.
[INFO] found chefmoisas on Home Assistant
1560415889: New client connected from 192.168.1.192 as DVES_51BF47 (c1, k10, u'chefmoisas').
1560415889: New connection from 192.168.1.136 on port 1883.
[INFO] found chefmoisas on Home Assistant
1560415892: New client connected from 192.168.1.136 as DVES_6B14F8 (c1, k10, u'chefmoisas').
1560415903: Socket error on client DVES_9218B4, disconnecting.
1560415904: New connection from 192.168.1.147 on port 1883.
[INFO] found chefmoisas on Home Assistant
1560415906: New client connected from 192.168.1.147 as DVES_9218B4 (c1, k10, u'chefmoisas').
1560415915: Socket error on client DVES_938B73, disconnecting.
1560415926: New connection from 192.168.1.109 on port 1883.
[INFO] found chefmoisas on Home Assistant
1560415928: New client connected from 192.168.1.109 as DVES_938B73 (c1, k10, u'chefmoisas').
1560415934: Socket error on client DVES_2C76ED, disconnecting.
1560415934: New connection from 192.168.1.195 on port 1883.
[INFO] found chefmoisas on Home Assistant
1560415936: New client connected from 192.168.1.195 as DVES_2C76ED (c1, k10, u'chefmoisas').
1560415940: Socket error on client DVES_457F27, disconnecting.
1560415941: New connection from 192.168.1.125 on port 1883.
[INFO] found chefmoisas on Home Assistant
1560415944: New client connected from 192.168.1.125 as DVES_457F27 (c1, k10, u'chefmoisas').
1560415950: Socket error on client DVES_6B14F8, disconnecting.
1560415950: New connection from 192.168.1.136 on port 1883.
[INFO] found chefmoisas on Home Assistant
1560415953: New client connected from 192.168.1.136 as DVES_6B14F8 (c1, k10, u'chefmoisas').
1560415968: Socket error on client DVES_0F51ED, disconnecting.
1560415968: Socket error on client DVES_EB047B, disconnecting.
1560415968: New connection from 192.168.1.193 on port 1883.
[INFO] found chefmoisas on Home Assistant
1560415970: New client connected from 192.168.1.193 as DVES_0F51ED (c1, k10, u'chefmoisas').
1560415978: New connection from 192.168.1.111 on port 1883.
[INFO] found chefmoisas on Home Assistant
1560415980: New client connected from 192.168.1.111 as DVES_EB047B (c1, k10, u'chefmoisas').

(Francisco Silva) #10

A mim também me acontece algo do género há algum tempo, por norma quando faço um reinicio completo ao HA ou quando há uma falha de energia. Ainda não consegui perceber o que o provoca…

HA v0.94.1.

CONFIG DO ADDON MOSQUITTO V4.3:

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

CONFIG DO ADDON ZIGBEE2MQTT V1.4.0:

{
  "data_path": "/share/zigbee2mqtt",
  "homeassistant": true,
  "permit_join": false,
  "mqtt_base_topic": "zigbee2mqtt",
  "mqtt_server": "mqtt://192.168.31.96:1883",
  "serial_port": "/dev/ttyACM0",
  "devices": [],
  "network_key": [],
  "mqtt_user": "xxxx",
  "mqtt_pass": "xxxx",
  "log_level": "info"
}

Não tenho nada do MQTT no ficheiro de configuração…
Tenho o MQTT nas integrações…

Só o consigo ressuscitar depois de uns restarts nos addons…

Alguma luz sobre o assunto?


(Jorge Assunção) #11

Depois de reiniciar o HA esse é o comportamento normal dos dispositivos ligados através do Z2M. Podes contornar o problema se colocares retain: true nos dispositivos.


(Francisco Silva) #12

e quanto aos outros do MQTT? Switchs e afins?


(Jorge Assunção) #13

Podes fazer o mesmo mas apenas poderá solucionar a questão da falta de informação inicial após o reboot do HA.


(Luis Alves) #14

Boa tarde Amigos

Continuo com o mesmo problema de x em x tempo os dispositivos ficam indisponiveis

J_assuncao tens mais alguma solução ?


(Rodolfo) #15

@chefmoisas quando falas em x tempo falas de largos minutos/horas ou apenas de alguns segundos?


(Luis Alves) #16

@RodolfoVieira os dispositivos ficam indisponiveis passado umas horas .


(Rodolfo) #17

O equipamento onde tens instalado o HA está ligado via wi-fi ou por cabo?


(Luis Alves) #18

@RodolfoVieira esta instalado num raspberry 3 e ligado por cabo


(Rodolfo) #19

Olhando de novo para todo o tópico penso que o problema está mesmo no próprio Addon.
Tens algum Snapshot onde tenhas o Addon do mosquito mais antigo?
Caso não tenhas, desinstala o Addon…reinicia depois a máquina do HA, e volta a instalar de novo o Addon.


(Francisco Silva) #20

No meu caso fiz a última parte mas sem sucesso…
Começo a pensar que tem alguma coisa a ver com o zigbee2mqtt…
Tenho de arranjar algum tempo para fazer mais testes…


(Rodolfo) #21

@fsilva80
passa no discord e fala comigo , para nos tentarmos uma coisa


(Francisco Silva) #22

Após conversa com o @RodolfoVieira e testando o downgrade do addon do Mosquitto broker para a versão 4.0 , o meu problema aparentemente ficou resolvido…