Rocka84 / esphome_components

10 stars 4 forks source link

Response first after second command sent #4

Open WhippingBoy01 opened 5 months ago

WhippingBoy01 commented 5 months ago

Seems like i somehow have to "wake" the code with the first butten pressed. Then after first command i response to every button clik. but if wait 10-15 sec after last command i need to push twice again.

here is my code:

substitutions:
  name: esphome-mittzon
  friendly_name: mittzon

esphome:
  name: ${name}
  friendly_name: ${friendly_name}
  name_add_mac_suffix: false
  project:
    name: esphome.web
    version: '1.0'
  on_boot:
    # This script is required to initialize the following sensors:
    #    height_pct, height_min, height_max, position1 - position4
    # You can skip this if you don't use those.
    priority: 0 # when mostly everything else is done
    then:
      - lambda: "id(my_desk).request_physical_limits();"
      - delay: 0.1s # give controller a chance to handle the response before sending the next command
      - lambda: "id(my_desk).request_limits();"
      - delay: 0.1s
      - lambda: "id(my_desk).request_settings();"

external_components:
  - source:
      #type: local
      #path: rocka84_esphome_components/components/
      type: git
      url: https://github.com/Rocka84/esphome_components/
    components: [ jiecang_desk_controller ]

uart:
  id: uart_bus
  tx_pin: TX
  rx_pin: RX
  baud_rate: 9600

logger:
  baud_rate: 0 # disable logging over uart, required when using the RX/TX pins for the controller

jiecang_desk_controller:
  id: my_desk
  buttons:
    move_up:
      name: "Move up"
    move_down:
      name: "Move down"
    stop:
      name: "Stop"
    step_up:
      name: "Step up"
    step_down:
      name: "Step down"
    position1:
      name: "Position 1"
    position2:
      name: "Position 2"
    position3:
      name: "Position 3"
    position4:
      name: "Position 4"
  numbers:
    height:
      name: "Height"

esp8266:
  board: esp01_1m

# Enable Home Assistant API
api:

# Allow Over-The-Air updates
ota:
  - platform: esphome

# Allow provisioning Wi-Fi via serial
#improv_serial:

wifi:
  # Set up a wifi access point
  ap: {}

# In combination with the `ap` this allows the user
# to provision wifi credentials to the device via WiFi AP.
captive_portal:

dashboard_import:
  package_import_url: github://esphome/example-configs/esphome-web/esp8266.yaml@main
  import_full_config: true

# To have a "next url" for improv serial
web_server:

I have tried with both simple and advanced code.

here is out put from the log.

[12:53:50][D][sensor:093]: 'Heap Max Block': Sending state 21088.00000 B with 0 decimals of accuracy [12:53:50][D][sensor:093]: 'Heap Fragmentation': Sending state 10.00000 % with 1 decimals of accuracy [12:53:54][D][button:010]: 'Step up' Pressed. [12:53:55][D][sensor:093]: 'Heap Free': Sending state 29720.00000 B with 0 decimals of accuracy [12:53:55][D][sensor:093]: 'Loop Time': Sending state 13.00000 ms with 0 decimals of accuracy [12:53:55][D][sensor:093]: 'Heap Max Block': Sending state 21088.00000 B with 0 decimals of accuracy [12:53:55][D][sensor:093]: 'Heap Fragmentation': Sending state 10.00000 % with 1 decimals of accuracy [12:53:56][D][button:010]: 'Step up' Pressed. [12:53:56][D][number:012]: 'Height': Sending state 83.500000 [12:53:56][D][number:012]: 'Height': Sending state 83.800003 [12:53:57][D][number:012]: 'Height': Sending state 84.400002 [12:53:57][D][number:012]: 'Height': Sending state 84.900002 [12:53:57][D][number:012]: 'Height': Sending state 85.000000 [12:54:00][D][sensor:093]: 'Heap Free': Sending state 29720.00000 B with 0 decimals of accuracy

Software versions and model 2024.6.3|Flash: 1024kB Speed:40MHz Mode:DOUT|Chip: 0x006546c7|SDK: 2.2.2-dev(38a443e)|Core: 3.1.2|Boot: 31|Mode: 1|CPU: 80|Flash: 0x00164020|Reset: Software/System restart|Software/System restart

Rocka84 commented 2 months ago

Hi @WhippingBoy01 Could you provide your config including indentations? Please use a code-block for that.

As is it is quit hard to read and I can't spot anything wrong.

Rocka84 commented 2 months ago

P.S.: Which control box do you have? If you're not sure you can compare yours to the ones here: https://www.jiecang.com/product/control-boxes.html

brendann993 commented 1 week ago

Im seeing the same issue. You can see here that the first push sent the uart data but nothing occured but I pushed the second time and the desk moved. If I then let it sit idle for a few seconds and try again it requires the double push again. Controller is JCB36NE2AP-230

[20:33:12][D][button:010]: 'Step up' Pressed.
[20:33:12][V][JiecangDeskController:225]: button_press_action 0
[20:33:12][D][uart_debug:176]: >>> 241,241,1,0,1,126
[20:33:12][D][uart_debug:114]: >>> F1,F1,01,00,01,7E
[20:33:12][D][custom:045]: Bytes size: 6
[20:33:13][D][button:010]: 'Step up' Pressed.
[20:33:13][V][JiecangDeskController:225]: button_press_action 0
[20:33:13][D][uart_debug:176]: >>> 241,241,1,0,1,126
[20:33:13][D][uart_debug:114]: >>> F1,F1,01,00,01,7E
[20:33:13][D][custom:045]: Bytes size: 6
[20:33:13][D][uart_debug:176]: <<< 242,242,1,3,4,95,7,110,126
[20:33:13][D][uart_debug:114]: <<< F2,F2,01,03,04,5F,07,6E,7E
[20:33:13][D][custom:045]: Bytes size: 9
[20:33:13][V][jiecang_desk_controller:056]: height 0x45F
[20:33:14][D][uart_debug:176]: <<< 242,242,1,3,4,96,7,111,126
[20:33:14][D][uart_debug:114]: <<< F2,F2,01,03,04,60,07,6F,7E
[20:33:14][D][custom:045]: Bytes size: 9
[20:33:14][V][jiecang_desk_controller:056]: height 0x460
[20:33:14][V][sensor:043]: 'Height': Received new state 112.000000
[20:33:14][D][sensor:094]: 'Height': Sending state 112.00000 cm with 1 decimals of accuracy
[20:33:14][D][number:012]: 'Height': Sending state 112.000000
[20:33:14][V][sensor:043]: 'Height Percent': Received new state 78.333336
[20:33:14][D][sensor:094]: 'Height Percent': Sending state 78.33334 % with 1 decimals of accuracy
[20:33:14][D][number:012]: 'Height Percent': Sending state 78.300003
[20:33:14][W][component:237]: Component jiecang_desk_controller took a long time for an operation (68 ms).
[20:33:14][W][component:238]: Components should block for at most 30 ms.
[20:33:14][D][uart_debug:176]: <<< 242,242,1,3,4,100,7,115,126
[20:33:14][D][uart_debug:114]: <<< F2,F2,01,03,04,64,07,73,7E
[20:33:14][D][custom:045]: Bytes size: 9
[20:33:14][V][jiecang_desk_controller:056]: height 0x464