# Automação downlights philips zhirui

**URL:** <https://forum.cpha.pt/t/automacao-downlights-philips-zhirui/1322>\
**Category:** Dúvidas\
**Created:** [4 Novembro , 2018 09:18 UTC](https://forum.cpha.pt/t/automacao-downlights-philips-zhirui/1322 "2018-11-04T09:18:51Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxcalavera](https://forum.cpha.pt/user_avatar/forum.cpha.pt/maxcalavera/32/1039_2.png) [@maxcalavera](https://forum.cpha.pt/u/maxcalavera)\
**Post date:** [4 Novembro , 2018 09:18 UTC](https://forum.cpha.pt/t/automacao-downlights-philips-zhirui/1322/1 "2018-11-04T09:18:52Z")

</div>

Bom dia pessoal, estou a tentar automatizar as minhas downlights da xiaomi philips zhirui, mas nao estou a conseguir não sei muito bem porquê. será que alguém me consegue ajudar?

A minha automação

```
  - alias: Ligar 18h00 20h00
    initial_state: true
    trigger:
      platform: state
      entity_id: binary_sensor.motion_sensor_158d00029be9c3
      from: 'off'
      to: 'on'
    condition:
    - condition: time
      after: '18:00:00'
      before: '20:00:00'
    - condition: numeric_state
      entity_id: sensor.illumination_158d00029be9c3
      below: 15
    action:
      - service: light.turn_on
        entity_id: light.downlight_cozinha_entrada
        data:
          Brightness: 100
          Scene : 1
      - service: light.turn_on
        data:
          entity_id: binary_sensor.motion_sensor_158d00029be9c3

```

configuration.yaml está assim

```
light:
  - platform: yeelight
    devices:
     xxx.xxx.x.xxx:
        name: yeelight_rgb_7811dc6b09nm
  - platform: xiaomi_miio
    name: Downlight Cozinha Entrada
    host: xxx.xxx.x.xxx
    token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    model: philips.light.bulb
  - platform: xiaomi_miio
    name: Downlight Cozinha Janela
    host: xxx.xxx.x.xxx
    token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    model: philips.light.bulb

```

e o erro que o home assistant reporta:

```
2018-11-04 09:06:26 WARNING (MainThread) [homeassistant.config] Package portao contains invalid customize
2018-11-04 09:06:26 WARNING (MainThread) [homeassistant.config] Package cozinha contains invalid customize
2018-11-04 09:06:51 ERROR (SyncWorker_3) [homeassistant.components.light.yeelight] Failed to connect to bulb xxx.xxx.x.xxx, yeelight_rgb_7811dc6b09nm: A socket error occurred when sending the command.
2018-11-04 09:07:00 ERROR (MainThread) [homeassistant.core] Timer got out of sync. Resetting
2018-11-04 09:07:10 ERROR (MainThread) [homeassistant.helpers.entity] Update for media_player.radio fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/jsonrpc_async/jsonrpc.py", line 29, in send_message
    response = yield from self._request(data=message.serialize())
  File "/usr/local/lib/python3.6/site-packages/aiohttp/client.py", line 391, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.6/site-packages/aiohttp/client_reqrep.py", line 770, in start
    self._continue = None
  File "/usr/local/lib/python3.6/site-packages/aiohttp/helpers.py", line 673, in __exit__
    raise asyncio.TimeoutError from None
concurrent.futures._base.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 347, in async_device_update
    await self.async_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/kodi.py", line 479, in async_update
    'albumartist', 'showtitle', 'album', 'season', 'episode']
  File "/usr/local/lib/python3.6/site-packages/jsonrpc_async/jsonrpc.py", line 31, in send_message
    raise TransportError('Transport Error', message, exc)
jsonrpc_base.jsonrpc.TransportError: ("Error calling method 'Player.GetItem': Transport Error", TimeoutError())

```

Obrigado pela vossa ajuda.

---

<div class="post-metadata">

**Author:** ![RodolfoVieira](https://forum.cpha.pt/user_avatar/forum.cpha.pt/rodolfovieira/32/14633_2.png) [@RodolfoVieira](https://forum.cpha.pt/u/RodolfoVieira)\
**Post date:** [4 Novembro , 2018 13:47 UTC](https://forum.cpha.pt/t/automacao-downlights-philips-zhirui/1322/2 "2018-11-04T13:47:15Z")

</div>

Essas lampadas não têm um token?

---

<div class="post-metadata">

**Author:** ![maxcalavera](https://forum.cpha.pt/user_avatar/forum.cpha.pt/maxcalavera/32/1039_2.png) [@maxcalavera](https://forum.cpha.pt/u/maxcalavera)\
**Post date:** [4 Novembro , 2018 13:58 UTC](https://forum.cpha.pt/t/automacao-downlights-philips-zhirui/1322/3 "2018-11-04T13:58:40Z")

</div>

Sim @rodolfoVieira e está configurado mas eu apaguei para não postar aqui o token…  
Elas aparecem no HA e informação do estado. Mas não consigo que a automação funcione.

---

<div class="post-metadata">

**Author:** ![RodolfoVieira](https://forum.cpha.pt/user_avatar/forum.cpha.pt/rodolfovieira/32/14633_2.png) [@RodolfoVieira](https://forum.cpha.pt/u/RodolfoVieira)\
**Post date:** [4 Novembro , 2018 14:12 UTC](https://forum.cpha.pt/t/automacao-downlights-philips-zhirui/1322/4 "2018-11-04T14:12:44Z")

</div>

Quak é o valor que agora aparece em sensor.illumination\_158d00029be9c3 ?

E já exprimentas-te tirar na automação o **Scene : 1**

---

<div class="post-metadata">

**Author:** ![maxcalavera](https://forum.cpha.pt/user_avatar/forum.cpha.pt/maxcalavera/32/1039_2.png) [@maxcalavera](https://forum.cpha.pt/u/maxcalavera)\
**Post date:** [4 Novembro , 2018 14:22 UTC](https://forum.cpha.pt/t/automacao-downlights-philips-zhirui/1322/5 "2018-11-04T14:22:25Z")

</div>

E deixar so o Brightness? Isso ainda não. Mas agora reparei num erro. O : a seguir ao scene tem um espaço. Vou tentar tirar o espaço e depois tiro o scene a ver o que dá…

---

<div class="post-metadata">

**Author:** ![RodolfoVieira](https://forum.cpha.pt/user_avatar/forum.cpha.pt/rodolfovieira/32/14633_2.png) [@RodolfoVieira](https://forum.cpha.pt/u/RodolfoVieira)\
**Post date:** [4 Novembro , 2018 14:26 UTC](https://forum.cpha.pt/t/automacao-downlights-philips-zhirui/1322/6 "2018-11-04T14:26:26Z")

</div>

Sim primeiro ves se o valor está abaixo desse 15, se tiver acima não vai funcionar, e depois exprimenta a tirar o que te disse só retirar o Scene : 1

---

<div class="post-metadata">

**Author:** ![maxcalavera](https://forum.cpha.pt/user_avatar/forum.cpha.pt/maxcalavera/32/1039_2.png) [@maxcalavera](https://forum.cpha.pt/u/maxcalavera)\
**Post date:** [4 Novembro , 2018 14:28 UTC](https://forum.cpha.pt/t/automacao-downlights-philips-zhirui/1322/7 "2018-11-04T14:28:29Z")

</div>

Sim, isso eu sabia pois já tinha configurado um valor mais elevado para efeitos de teste… Vou tentar. Obrigado

---

<div class="post-metadata">

**Author:** ![maxcalavera](https://forum.cpha.pt/user_avatar/forum.cpha.pt/maxcalavera/32/1039_2.png) [@maxcalavera](https://forum.cpha.pt/u/maxcalavera)\
**Post date:** [4 Novembro , 2018 19:03 UTC](https://forum.cpha.pt/t/automacao-downlights-philips-zhirui/1322/8 "2018-11-04T19:03:37Z")

</div>

Já experimentei e não funciona. Não sei o que mais poderei alterar…

---

<div class="post-metadata">

**Author:** ![jpm](https://forum.cpha.pt/letter_avatar_proxy/v4/letter/j/b487fb/32.png) [@jpm](https://forum.cpha.pt/u/jpm)\
**Post date:** [5 Novembro , 2018 09:38 UTC](https://forum.cpha.pt/t/automacao-downlights-philips-zhirui/1322/9 "2018-11-05T09:38:14Z")

</div>

Bom dia.

Uma pergunta o que é a ultima entidade da tua automação?

```auto
      - service: light.turn_on
        data:
          entity_id: binary_sensor.motion_sensor_158d00029be9c3

```

Aproveito e peço-te que confirmes que tens o “Developer mode” enable na Yeelight mobile app?

---

<div class="post-metadata">

**Author:** ![maxcalavera](https://forum.cpha.pt/user_avatar/forum.cpha.pt/maxcalavera/32/1039_2.png) [@maxcalavera](https://forum.cpha.pt/u/maxcalavera)\
**Post date:** [5 Novembro , 2018 11:00 UTC](https://forum.cpha.pt/t/automacao-downlights-philips-zhirui/1322/10 "2018-11-05T11:00:09Z")

</div>

Essa última parte é erro da minha parte, o @RodolfoVieira já me alertou para esse erro. E como as automações funcionam nunca dei por nada. Quanto a developer mode penso que não faz falta uma vez que na App yeelight não aparecem lá e por parte do home assistant estão a funcionar. [https://www.dropbox.com/s/6v74y90d4zl4eey/Screenshot\_20181105-105527.png?dl=0](https://www.dropbox.com/s/6v74y90d4zl4eey/Screenshot_20181105-105527.png?dl=0)  
A única coisa que nao está a funcionar é mesmo as automações. Qualquer coisa que ali está mal… Tenho feito muitas pesquisas e ainda assim não consegui acertar com as automações.

---

<div class="post-metadata">

**Author:** ![jpm](https://forum.cpha.pt/letter_avatar_proxy/v4/letter/j/b487fb/32.png) [@jpm](https://forum.cpha.pt/u/jpm)\
**Post date:** [5 Novembro , 2018 11:07 UTC](https://forum.cpha.pt/t/automacao-downlights-philips-zhirui/1322/11 "2018-11-05T11:07:29Z")

</div>

A app é uma coisa, controlar “localmente” é outra e como podes ver neste topico tirando actualizar o HA só tens esse factor a testar.

[https://github.com/home-assistant/home-assistant/issues/4287](https://github.com/home-assistant/home-assistant/issues/4287)

---

<div class="post-metadata">

**Author:** ![maxcalavera](https://forum.cpha.pt/user_avatar/forum.cpha.pt/maxcalavera/32/1039_2.png) [@maxcalavera](https://forum.cpha.pt/u/maxcalavera)\
**Post date:** [5 Novembro , 2018 11:28 UTC](https://forum.cpha.pt/t/automacao-downlights-philips-zhirui/1322/12 "2018-11-05T11:28:46Z")

</div>

@jpm, eu consigo controlar as lâmpadas localmente no HA, consigo acender e apagar. O que não estou a conseguir é fazer automações. Se fores ao meu primeiro poste e fores ver o log do HA só dá erro nas configurações das automacões… As lâmpadas não têm qualquer tipo de erros…

```
2018-11-04 09:06:26 WARNING (MainThread) [homeassistant.config] Package portao contains invalid customize
    2018-11-04 09:06:26 WARNING (MainThread) [homeassistant.config] Package cozinha contains invalid customize
    2018-11-04 09:06:51 ERROR (SyncWorker_3) [homeassistant.components.light.yeelight] Failed to connect to bulb xxx.xxx.x.xxx, yeelight_rgb_7811dc6b09nm: A socket error occurred when sending the command.
    2018-11-04 09:07:00 ERROR (MainThread) [homeassistant.core] Timer got out of sync. Resetting
    2018-11-04 09:07:10 ERROR (MainThread) [homeassistant.helpers.entity] Update for media_player.radio fails
    Traceback (most recent call last):

```

O erro que estás a ver da yeelight é porque está desligada no interruptor… Mas as lâmpadas que falo são da xiaomi Philips zhirui. É está tudo devidamente bem configurado…

---

<div class="post-metadata">

**Author:** ![jpm](https://forum.cpha.pt/letter_avatar_proxy/v4/letter/j/b487fb/32.png) [@jpm](https://forum.cpha.pt/u/jpm)\
**Post date:** [5 Novembro , 2018 11:42 UTC](https://forum.cpha.pt/t/automacao-downlights-philips-zhirui/1322/13 "2018-11-05T11:42:27Z")

</div>

```auto
  - alias: Ligar 18h00 20h00
    initial_state: true
    trigger:
      platform: state
      entity_id: binary_sensor.motion_sensor_158d00029be9c3
      from: 'off'
      to: 'on'
    action:
      - service: light.turn_on
        entity_id: light.downlight_cozinha_entrada
        data:
          Brightness: 100

```

Testa e envia um log em modo debug com esta automação a correr, sffv.

---

<div class="post-metadata">

**Author:** ![maxcalavera](https://forum.cpha.pt/user_avatar/forum.cpha.pt/maxcalavera/32/1039_2.png) [@maxcalavera](https://forum.cpha.pt/u/maxcalavera)\
**Post date:** [5 Novembro , 2018 11:55 UTC](https://forum.cpha.pt/t/automacao-downlights-philips-zhirui/1322/14 "2018-11-05T11:55:17Z")

</div>

Já testei essa autorização. Não deu em nada, mas posso testar novamente, só não sei como fazer o modo debug…

Vê se é isto que me pediste…

Removido por motivos de segurança

---

<div class="post-metadata">

**Author:** ![jpm](https://forum.cpha.pt/letter_avatar_proxy/v4/letter/j/b487fb/32.png) [@jpm](https://forum.cpha.pt/u/jpm)\
**Post date:** [5 Novembro , 2018 13:41 UTC](https://forum.cpha.pt/t/automacao-downlights-philips-zhirui/1322/15 "2018-11-05T13:41:58Z")

</div>

Nada do teu log indica que essa automação foi executada, nem sequer que tentou e deu erro.

pesquisei pela hora 18h00 e pela entidade

```auto
downlight_cozinha_entrada

```

nenhum deles retornou o resultado esperado.

o log deve ter a execução da automação nem que seja de forma manual com um trigger manual da mesma.

---

<div class="post-metadata">

**Author:** ![maxcalavera](https://forum.cpha.pt/user_avatar/forum.cpha.pt/maxcalavera/32/1039_2.png) [@maxcalavera](https://forum.cpha.pt/u/maxcalavera)\
**Post date:** [5 Novembro , 2018 16:51 UTC](https://forum.cpha.pt/t/automacao-downlights-philips-zhirui/1322/16 "2018-11-05T16:51:37Z")

</div>

O problema é que ela nem sequer aparece no HA para poder executar manualmente… Simplesmente não existe… Começo a desconfiar do ficheiro .yaml. Mas também o ficheiro sem a automação funciona bem sem erros…

---

<div class="post-metadata">

**Author:** ![jpm](https://forum.cpha.pt/letter_avatar_proxy/v4/letter/j/b487fb/32.png) [@jpm](https://forum.cpha.pt/u/jpm)\
**Post date:** [5 Novembro , 2018 17:21 UTC](https://forum.cpha.pt/t/automacao-downlights-philips-zhirui/1322/17 "2018-11-05T17:21:14Z")

</div>

Excelente, então o primeiro passo ultrapassamos:

Essa automação não tem erros, simplesmente não é carregada

Segundo passo: tens a certeza que estas no ficheiro certo? Se sim porque dizes que sim. Se não onde é que está essa automação?

---

<div class="post-metadata">

**Author:** ![maxcalavera](https://forum.cpha.pt/user_avatar/forum.cpha.pt/maxcalavera/32/1039_2.png) [@maxcalavera](https://forum.cpha.pt/u/maxcalavera)\
**Post date:** [5 Novembro , 2018 17:56 UTC](https://forum.cpha.pt/t/automacao-downlights-philips-zhirui/1322/18 "2018-11-05T17:56:00Z")

</div>

Sim, estou no ficheiro cozinha.yaml que é onde tenho as minhas configurações para os periféricos que tenho na cozinha. Periféricos esses que são as xiaomi philips zhirui e sensor de movimento. A automação está dentro desse mesmo ficheiro que após o configurar lá e reiniciar o HA dá erro nesse mesmo ficheiro…

---

<div class="post-metadata">

**Author:** ![tmarquespt](https://forum.cpha.pt/user_avatar/forum.cpha.pt/tmarquespt/32/16063_2.png) [@tmarquespt](https://forum.cpha.pt/u/tmarquespt)\
**Post date:** [5 Novembro , 2018 19:27 UTC](https://forum.cpha.pt/t/automacao-downlights-philips-zhirui/1322/19 "2018-11-05T19:27:45Z")

</div>

@maxcalavera

Sugeria tirares a automação do ficheiro package e colocares no automations.yaml.

Por um motivo: alteras, gravas, fazes check, reload automations, e evitas estar sempre a reiniciar o HA. Quando estiver ok, se quiseres, voltas a colocar no package.

Não te resolve nada, mas poupas tempo 😉

---

<div class="post-metadata">

**Author:** ![tmarquespt](https://forum.cpha.pt/user_avatar/forum.cpha.pt/tmarquespt/32/16063_2.png) [@tmarquespt](https://forum.cpha.pt/u/tmarquespt)\
**Post date:** [5 Novembro , 2018 19:50 UTC](https://forum.cpha.pt/t/automacao-downlights-philips-zhirui/1322/20 "2018-11-05T19:50:46Z")

</div>

@maxcalavera conheces a função de verificar os ficheiros?

configuration → General e antes de carregares em Restart, carregas em check config

 ![image](https://forum.cpha.pt/uploads/default/original/2X/f/fd3933406325dc5ca8e31d5566f72ea372b5a07e.png)

diz-te logo quais os erros que tens e não precisas de estar a reinciar o HA com erros.

[Próxima página](https://forum.cpha.pt/t/automacao-downlights-philips-zhirui/1322.md?page=2)
