Vaarlion / Tic2MQTT

GNU General Public License v3.0
0 stars 0 forks source link

Not related to this rep.Just a request for another diy #1

Open spplecxer opened 2 months ago

spplecxer commented 2 months ago

Hi. Found your faac gate esp32 diy. Got it working but would like to add the last script and I am having a hard time šŸ˜€ Is it possible to add some info on how you implemented it in esphome please? I am using the last update of esphome and I have several errors when I add the code to the yaml. The scrip component on esphome documentation seems to work differently. Thanks.

https://vaarlion.com/blog/making-a-diy-wifi-gate-controller-using-esphome/

Vaarlion commented 2 months ago

Hi :) Do not hesitate to reach out using the mail form on the website, i do read those :D You can also comment under the gist provided :

Now, You are talking about script. There is a couple of lambda, but i don't use script in the esphome code. The gist with script is for home assistant and not esphome. It's a packages file you should just have to copy and paste in your packages folder inside home assistant.

It add extra logic without making the esphome side more complex.

I no-longer use packages, even if very practical, because the home assistant team is deprecating all manual Yaml config for GUI based editing.

So i would recommend that you manually rewrite the script inside home assistant script editor, and use this doc to create the template cover entity in your configuration.yaml

Does this make sens to you ?

spplecxer commented 2 months ago

Thanks for the quick reply.I was trying to add the gist to the esphome device yaml !! I am new to esphome and homeassistant so learning my way slowly. The kit is working with the intial code you posted. If you can help with adding the gist into the esphome device yaml that would be great. But Iā€™m happy with the kit though. Did you update your yaml or are you still using the script? If you updated the yaml do you mind sharing it?

Thanks a lot

Vaarlion commented 2 months ago

I am quite confuse, sorry ...

The kit is working with the intial code you posted

Yet you didn't put the code in the esp ? I have no idea how to guide you, because it depend on so many thing like what gate controller are you working with and how did you interface with it... and what's the wiring from that to you esp, what pin number ...

You need to create a new esphome project, and then add the section from this link, changing what doesn't match your installation.

button:
  - platform: safe_mode
    name: "Portal Safe Mode Boot"
    entity_category: diagnostic

  - platform: restart
    name: "Portal Restart"

cover:
  - platform: template
    name: "Portal"
    device_class: gate
    lambda: |-
      if (id(state_open).state) {
        return COVER_OPEN;
      } else {
        return COVER_CLOSED;
      }
    open_action:
      - output.turn_on: open_close_portal_full
    close_action:
      - output.turn_on: open_close_portal_full
    stop_action:
      - output.turn_on: stop_portal

sensor:
  - platform: duty_cycle
    id: input_state
    update_interval: 1s
    pin:
      number: D2 ## Here is the pin for the blinking light optocoupler
      mode: input_pullup
      inverted: true

  - platform: uptime
    name: Portal Uptime
    icon: mdi:clock-time-four-outline
    entity_category: "diagnostic"
  - platform: wifi_signal
    name: Portal WiFi Signal
    update_interval: 60s
    unit_of_measurement: "dBm"
    device_class: "signal_strength"
    state_class: "measurement"
    entity_category: "diagnostic"

  - platform: template
    name: "Portal State"
    id: state_open
    filters:
      - delayed_off: 1200ms
    lambda: |-
      if (id(input_state).state > 0) {
        // portal is open.
        return true;
      } else {
        // Portal is close.
        return false;
      }
  - platform: template
    name: "Portal closing"
    id: state_closing
    filters:
      - delayed_on_off: 1200ms
    lambda: |-
      if ( id(input_state).state > 1 and id(input_state).state < 99) {
        // portal is closing.
        return true;
      } else {
        // Portal is idle.
        return false;
      }

output:
  - platform: gpio
    pin: D5 ## Here is the pin for opening and closing half of the gate
    id: relay1
    inverted: True
  - platform: gpio
    pin: D6 ## Here is the pin for opening and closing the gate
    id: relay2
    inverted: True
  - platform: gpio
    pin: D7 ## Here is the pin for stopping the gate
    id: relay3
    inverted: True
# Pulse generator: This tell the relay to turn on then off quickly to simulate a button press
  - platform: template
    type: binary
    id: open_close_portal_full
    write_action:
      - output.turn_on: relay2
      - delay: 500ms
      - output.turn_off: relay2
  - platform: template
    type: binary
    id: open_close_portal_half
    write_action:
      - output.turn_on: relay1
      - delay: 500ms
      - output.turn_off: relay1
  - platform: template
    type: binary
    id: stop_portal
    write_action:
      - output.turn_on: relay3
      - delay: 500ms
      - output.turn_off: relay3