HomeAssistant(13) - HelloMorningStar/HomeAssistant GitHub Wiki

auto slide curtain with dooya sunflower moto

1, install auto slide curtain rail and sunflower moto

cost: 320RMB (about 42.59 us dollar) incloud 3.5m one slide rail and one sunflower moto kt320e and 433MHz remoter.

2, the first method is use 4lines dry connector ADBC by esp01 with 2 relay to control auto curtain

1) prepare 1 esp01s/ 2 relays/ 1 switch input 220v and output 5.0v power supply

sudo gedit configuration.yaml make a boolean switch

input_boolean:
  curtain1:
    name: (关/开)窗帘 #(close/open curtain)
    initial: off

sudo gedit automations.yaml #use boolean values as a trigger for closing or opening curtain

#automation:
  - alias: close curtain
    initial_state: true
    hide_entity: true
    trigger:
      - platform: state
        entity_id: input_boolean.curtain1
        from: 'on'
        to: 'off'
    action:
      - service: script.master_room_curtain1_close
        entity_id: input_boolean.curtain1
  - alias: open curtain
    initial_state: true
    hide_entity: true
    trigger:
      - platform: state
        entity_id: input_boolean.curtain1
        from: 'off'
        to: 'on'
    action:
      - service: script.master_room_curtain1_open
        entity_id: input_boolean.curtain1

sudo gedit scripts.yaml #script actions

master_room_curtain1_open:
  sequence:
    - service: homeassistant.turn_off
      entity_id: 'switch.sonoff'
    - service: homeassistant.turn_on
      entity_id: 'switch.sonoff2_4'
master_room_curtain1_close:
  sequence:
    - service: homeassistant.turn_off
      entity_id: 'switch.sonoff2_4'
    - service: homeassistant.turn_on
      entity_id: 'switch.sonoff'

last, in the homeassistant -> overview -> configura UI
add entity input_boolean.curtain1
now, we can control auto curtain close or open in homeassistant and homekit

3, the 2nd method is use RF433 transmit and receive to control dooya kt320e moto

install rpi on raspberry https://pypi.org/project/rpi-rf/
reference to https://www.home-assistant.io/integrations/rpi_rf/

Log Details (ERROR)
Wed Oct 16 2019 20:54:02 GMT+0800 (China Standard Time)
Error while setting up platform rpi_rf
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 149, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/rpi_rf/switch.py", line 46, in setup_platform
    rpi_rf = importlib.import_module("rpi_rf")
  File "/srv/homeassistant/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 994, in _gcd_import
  File "", line 971, in _find_and_load
  File "", line 955, in _find_and_load_unlocked
  File "", line 665, in _load_unlocked
  File "", line 678, in exec_module
  File "", line 219, in _call_with_frames_removed
  File "/srv/homeassistant/lib/python3.6/site-packages/rpi_rf/__init__.py", line 2, in 
    from .rpi_rf import RFDevice
  File "/srv/homeassistant/lib/python3.6/site-packages/rpi_rf/rpi_rf.py", line 9, in 
    from RPi import GPIO
  File "/srv/homeassistant/lib/python3.6/site-packages/RPi/GPIO/__init__.py", line 23, in 
    from RPi._GPIO import *
RuntimeError: This module can only be run on a Raspberry Pi!

raspberry pi3 was installed ubuntu18 64bit ver, it is a issue, maybe change to 32bit ver can do it.
try: https://discourse.osmc.tv/t/gpio-permissions/38931/2
and
https://raspberrypi.stackexchange.com/questions/40105/access-gpio-pins-without-root-no-access-to-dev-mem-try-running-as-root

⚠️ **GitHub.com Fallback** ⚠️