mirror of
https://github.com/randybb/esphome-configs.git
synced 2026-01-02 19:47:29 +01:00
Start playing with CANopen
This commit is contained in:
@@ -13,12 +13,14 @@ esp32:
|
|||||||
board: esp32dev
|
board: esp32dev
|
||||||
framework:
|
framework:
|
||||||
type: esp-idf
|
type: esp-idf
|
||||||
version: 5.3.1
|
# version: 5.3.1
|
||||||
platform_version: 6.9.0
|
# platform_version: 6.9.0
|
||||||
|
|
||||||
external_components:
|
external_components:
|
||||||
- source: github://mrk-its/esphome-canopen@dev
|
- source: github://mrk-its/esphome-canopen@dev
|
||||||
refresh: 1h
|
refresh: 1h
|
||||||
|
- source: github://mrk-its/esphome-canbus-udp-multicast@dev
|
||||||
|
refresh: 1h
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
common: !include common/common.yaml
|
common: !include common/common.yaml
|
||||||
@@ -28,65 +30,94 @@ canbus:
|
|||||||
id: can_bus
|
id: can_bus
|
||||||
rx_pin: 22
|
rx_pin: 22
|
||||||
tx_pin: 23
|
tx_pin: 23
|
||||||
can_id: 0
|
can_id: 1
|
||||||
bit_rate: 125kbps
|
bit_rate: 500kbps
|
||||||
|
|
||||||
canopen:
|
canopen:
|
||||||
id: can_gate
|
id: can_open
|
||||||
canbus_id: can_bus
|
canbus_id: can_bus
|
||||||
node_id: 1
|
node_id: 1
|
||||||
entities:
|
entities:
|
||||||
- id: boot
|
- index: 1
|
||||||
index: 1
|
id: light1_state
|
||||||
|
rpdo:
|
||||||
|
- node_id: 2
|
||||||
tpdo: 0
|
tpdo: 0
|
||||||
- id: blue_led
|
offset: 0
|
||||||
index: 2
|
cmd: 0
|
||||||
tpdo: 0
|
|
||||||
- id: uptime_sensor
|
|
||||||
index: 3
|
|
||||||
tpdo: 0
|
|
||||||
- id: cover1
|
|
||||||
index: 4
|
|
||||||
tpdo: 1
|
|
||||||
# - id: cover2
|
|
||||||
# index: 5
|
|
||||||
# tpdo: 1
|
|
||||||
|
|
||||||
sensor:
|
- index: 2
|
||||||
- platform: uptime
|
id: light1_brightness
|
||||||
id: uptime_sensor
|
size: 1
|
||||||
name: "${name} Uptime"
|
min_value: 0.0
|
||||||
update_interval: 5sec
|
max_value: 1.0
|
||||||
internal: true
|
rpdo:
|
||||||
|
- node_id: 2
|
||||||
|
tpdo: 0
|
||||||
|
offset: 1
|
||||||
|
cmd: 0
|
||||||
|
|
||||||
|
- index: 3
|
||||||
|
id: light2_state
|
||||||
|
rpdo:
|
||||||
|
- node_id: 2
|
||||||
|
tpdo: 0
|
||||||
|
offset: 3
|
||||||
|
cmd: 0
|
||||||
|
|
||||||
|
- index: 4
|
||||||
|
id: light2_brightness
|
||||||
|
size: 1
|
||||||
|
min_value: 0.0
|
||||||
|
max_value: 1.0
|
||||||
|
rpdo:
|
||||||
|
- node_id: 2
|
||||||
|
tpdo: 0
|
||||||
|
offset: 4
|
||||||
|
cmd: 0
|
||||||
|
|
||||||
binary_sensor:
|
binary_sensor:
|
||||||
|
- platform: template
|
||||||
|
id: light1_state
|
||||||
|
name: "Test Light 1 State"
|
||||||
|
- platform: template
|
||||||
|
id: light2_state
|
||||||
|
name: "Test Light 2 State"
|
||||||
|
|
||||||
|
- platform: template
|
||||||
|
id: light1_state_cmd
|
||||||
|
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
name: "${name} Boot"
|
name: "Boot Button"
|
||||||
id: boot
|
id: boot_button
|
||||||
internal: true
|
|
||||||
pin:
|
pin:
|
||||||
number: 0
|
number: 0
|
||||||
inverted: true
|
inverted: true
|
||||||
|
mode:
|
||||||
|
input: true
|
||||||
|
pullup: true
|
||||||
|
on_press:
|
||||||
|
then:
|
||||||
|
- lambda: |-
|
||||||
|
bool state = id(light1_state).state || id(light2_state).state;
|
||||||
|
|
||||||
|
// send command to entity #1 (light) on node #2
|
||||||
|
id(can_open).send_entity_cmd(2, 1, !state);
|
||||||
|
|
||||||
|
// send command to entity #2 (light2) on node #2
|
||||||
|
id(can_open).send_entity_cmd(2, 2, !state);
|
||||||
|
|
||||||
|
sensor:
|
||||||
|
- platform: template
|
||||||
|
id: light1_brightness
|
||||||
|
name: "Test Light 1 Brightness"
|
||||||
|
- platform: template
|
||||||
|
id: light2_brightness
|
||||||
|
name: "Test Light 2 Brightness"
|
||||||
|
|
||||||
switch:
|
switch:
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
name: "${name} Led"
|
name: "Led"
|
||||||
id: blue_led
|
id: blue_led
|
||||||
internal: true
|
internal: true
|
||||||
pin: 2
|
pin: 2
|
||||||
|
|
||||||
cover:
|
|
||||||
- platform: time_based
|
|
||||||
name: "${name} Cover"
|
|
||||||
id: cover1
|
|
||||||
internal: true
|
|
||||||
device_class: shutter
|
|
||||||
has_built_in_endstop: true
|
|
||||||
open_action:
|
|
||||||
- logger.log: open_action
|
|
||||||
open_duration: 10s
|
|
||||||
close_action:
|
|
||||||
- logger.log: close_action
|
|
||||||
close_duration: 10s
|
|
||||||
stop_action:
|
|
||||||
- logger.log: stop_action
|
|
||||||
|
|||||||
@@ -13,12 +13,14 @@ esp32:
|
|||||||
board: esp32dev
|
board: esp32dev
|
||||||
framework:
|
framework:
|
||||||
type: esp-idf
|
type: esp-idf
|
||||||
version: 5.3.1
|
# version: 5.3.2
|
||||||
platform_version: 6.9.0
|
# platform_version: 53.03.11
|
||||||
|
|
||||||
external_components:
|
external_components:
|
||||||
- source: github://mrk-its/esphome-canopen@dev
|
- source: github://mrk-its/esphome-canopen@dev
|
||||||
refresh: 1h
|
refresh: 1h
|
||||||
|
- source: github://mrk-its/esphome-canbus-udp-multicast@dev
|
||||||
|
refresh: 1h
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
common: !include common/common.yaml
|
common: !include common/common.yaml
|
||||||
@@ -28,65 +30,77 @@ canbus:
|
|||||||
id: can_bus
|
id: can_bus
|
||||||
rx_pin: 22
|
rx_pin: 22
|
||||||
tx_pin: 23
|
tx_pin: 23
|
||||||
can_id: 0
|
can_id: 2
|
||||||
bit_rate: 125kbps
|
bit_rate: 500kbps
|
||||||
|
|
||||||
canopen:
|
canopen:
|
||||||
id: can_gate
|
id: can_open
|
||||||
canbus_id: can_bus
|
canbus_id: can_bus
|
||||||
node_id: 2
|
node_id: 2
|
||||||
entities:
|
entities:
|
||||||
- id: boot
|
- index: 1
|
||||||
index: 1
|
id: light1
|
||||||
tpdo: 0
|
tpdo: 0
|
||||||
- id: blue_led
|
|
||||||
index: 2
|
- index: 2
|
||||||
|
id: light2
|
||||||
tpdo: 0
|
tpdo: 0
|
||||||
- id: uptime_sensor
|
|
||||||
index: 3
|
- index: 3
|
||||||
|
id: light3
|
||||||
tpdo: 0
|
tpdo: 0
|
||||||
- id: cover1
|
|
||||||
index: 4
|
|
||||||
tpdo: 1
|
|
||||||
# - id: cover2
|
|
||||||
# index: 5
|
|
||||||
# tpdo: 1
|
|
||||||
|
|
||||||
sensor:
|
output:
|
||||||
- platform: uptime
|
- platform: template
|
||||||
id: uptime_sensor
|
id: cw_output1
|
||||||
name: "${name} Uptime"
|
type: float
|
||||||
update_interval: 5sec
|
write_action:
|
||||||
internal: true
|
- logger.log:
|
||||||
|
format: "output1: %f"
|
||||||
|
args: ['state']
|
||||||
|
|
||||||
binary_sensor:
|
- platform: template
|
||||||
- platform: gpio
|
id: ww_output1
|
||||||
name: "${name} Boot"
|
type: float
|
||||||
id: boot
|
write_action:
|
||||||
internal: true
|
- logger.log:
|
||||||
pin:
|
format: "output2: %f"
|
||||||
number: 0
|
args: ['state']
|
||||||
inverted: true
|
|
||||||
|
|
||||||
switch:
|
- platform: template
|
||||||
- platform: gpio
|
id: output2
|
||||||
name: "${name} Led"
|
type: float
|
||||||
id: blue_led
|
write_action:
|
||||||
internal: true
|
- logger.log:
|
||||||
pin: 2
|
format: "output1: %f"
|
||||||
|
args: ['state']
|
||||||
|
|
||||||
cover:
|
- platform: template
|
||||||
- platform: time_based
|
id: output3
|
||||||
name: "${name} Cover"
|
type: float
|
||||||
id: cover1
|
write_action:
|
||||||
internal: true
|
- logger.log:
|
||||||
device_class: shutter
|
format: "output1: %f"
|
||||||
has_built_in_endstop: true
|
args: ['state']
|
||||||
open_action:
|
|
||||||
- logger.log: open_action
|
light:
|
||||||
open_duration: 10s
|
- platform: cwww
|
||||||
close_action:
|
id: light1
|
||||||
- logger.log: close_action
|
name: "${name} Light 1"
|
||||||
close_duration: 10s
|
cold_white: cw_output1
|
||||||
stop_action:
|
warm_white: ww_output1
|
||||||
- logger.log: stop_action
|
cold_white_color_temperature: 6536 K
|
||||||
|
warm_white_color_temperature: 2000 K
|
||||||
|
constant_brightness: false
|
||||||
|
default_transition_length: 0s
|
||||||
|
|
||||||
|
- platform: monochromatic
|
||||||
|
id: light2
|
||||||
|
name: "${name} Light 2"
|
||||||
|
output: output2
|
||||||
|
default_transition_length: 0s
|
||||||
|
|
||||||
|
- platform: binary
|
||||||
|
id: light3
|
||||||
|
name: "${name} Light 3"
|
||||||
|
output: output3
|
||||||
|
|||||||
Reference in New Issue
Block a user