esphome_components's Introduction
esphome_components's People
Forkers
elvitesphome_components's Issues
Feature Request: Add Motion Detection Sensor
Hello again;)
The Desky custom component on the RJ45 port tracks the state of the desk in a similar way to some cover components.
https://github.com/ssieb/esphome_components/tree/master/components/desky
binary_sensor:
- platform: template
name: Desky moving
lambda: return id(my_desky).current_operation != desky::DESKY_OPERATION_IDLE;
It would be nice to have a similar feature for your component. I think this also sets up for a “cover” type set-up which I’ll have a play with and raise a separate feature request for soonish.
I came up with this yaml based approach. It works by watching for changes in height (which seems simple to do via on_value
since height
seems to only update on changes) .
Since we aren't measuring something directly I guess this relies on the contoller being honest about what it is sending, and an assumption about a "motion timeout".
I think this kind of sensor then sets up a for a nicer "cover" implementation.
I don't know whether my approach is any good, I guess doing it at a lower level (maybe just by tracking byte 5?) might be better.
Also I haven't thought through whether there may be some safety related aspect to this if the motion is "assumed" to some extent.
Let me know your thoughts.
numbers:
height:
name: "Height"
id: height_id
on_value: # When height changes, publish the desk state as "moving" with a small timeout for "not moving"
then:
- binary_sensor.template.publish:
id: desk_is_moving
state: True
- delay: 100ms
- binary_sensor.template.publish:
id: desk_is_moving
state: False
# Calculate the change in height and publish it to a new sensor
# You could use something like this to track the direction of movement of the desk?
# - lambda: |-
# static float last_value = 0;
# float change = 0;
# change = x - last_value;
# last_value = x;
# return id(height_delta).publish_state(change);
# sensor:
# - platform: template
# id: height_delta
# name: "height delta"
# internal: false
binary_sensor:
- platform: template
id: desk_is_moving
name: "Desk is Moving"
filters:
- delayed_off: 300ms # Probably this should relate to the height message update frequency. Seems to work ok for me.
Response first after second command sent
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
Feature Request: Add "Cover" features.
- Cover components provide a tidy little gui for controlling things like desks.
- There are various implementation options available (like the option to track "position").
- I knocked up a very basic one in yaml and to be honest even this basic one works quite well and could potentially be included in your example config.
- A richer implementation might infer endstops from current height and limits, track if the desk is moving and in which direction (inferred from height messages?), and enable position control.
- I thought I would use a "motion sensor" for it, but didn't use it in the end.
numbers:
# height_pct:
# name: "Height Percent"
# id: height_percent_id
height:
name: "Height"
id: height_id
on_value: # When height changes, publish the desk state as "moving" with a timeout for "not moving"
then:
- binary_sensor.template.publish:
id: desk_is_moving
state: True
- delay: 100ms
- binary_sensor.template.publish:
id: desk_is_moving
state: False
cover:
# Template cover provides a simple gui for up / down / stop.
# There's options for more advanced set-up which would need more looking into I guess.
# Below cover operates very "optimistically".
# To be honest even just this bare bones yaml config is not that bad feature wise.
- platform: template
name: "Desk"
icon: mdi:desk
open_action:
- button.press: move_up
# open_sensor: # Not used. From "Template cover", which has some more interesting options". https://esphome.io/components/cover/template.html
close_action:
- button.press: move_down
# open_sensor: # Not used. From "Template cover".
stop_action:
- button.press: stop
assumed_state: true
optimistic: true
# has_position: true # Might be able to use height_percent_id ?
# position_action: # Might be able to use id(my_desk).goto_height(pos) with some mods to convert from % height to height?
binary_sensor:
# Didn't end up using this for the cover in the end.
- platform: template
id: desk_is_moving
name: "Desk is Moving"
filters:
- delayed_off: 300ms # Probably this should relate to the height message update frequency. Seems to work ok for me.
Add fully up and fully down button's
Hey it's Mahko_Mahko from the Desky thread.
I was just tinkering with your project which I think is very nice.
One idea was to add buttons that on a single press send the desk fully up / down (and can be stopped by the stop button and desk buttons).
I came up with this yaml that seems to work ok, but maybe you can provide more native support (or add something similar as optional config to your repo etc. For my desk it stops on any button press.
Just a small idea. Cheers.
jiecang_desk_controller:
id: my_desk
buttons:
raise:
name: "Raise"
lower:
name: "Lower"
stop:
name: "Stop"
position1:
name: "Position 1"
position2:
name: "Position 2"
position3:
name: "Position 3"
position4:
name: "Position 4"
numbers:
height:
name: "Height"
sensors:
height_max:
name: "Height Max"
id: height_max_id
height_min:
name: "Height Min"
id: height_min_id
button:
- platform: template
name: "Fully Down"
on_press:
then:
- lambda: id(my_desk).goto_height(id(height_min_id).state);
- platform: template
name: "Fully Up"
on_press:
then:
- lambda: id(my_desk).goto_height(id(height_max_id).state);
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.