mirror of
https://github.com/randybb/esphome-configs.git
synced 2026-12-06 01:06:52 +01:00
can-node-1/2: canopen_entities from mrk-its/esphome-canopen@canopen_entities
This commit is contained in:
1 parent
8aee65e697
commit
feaa161653
2 files changed
+33
-56
No files matched your search
+29
-53
@@ -24,9 +24,8 @@ esp32:
|
|||||||
type: esp-idf
|
type: esp-idf
|
||||||
|
|
||||||
external_components:
|
external_components:
|
||||||
- source: github://mrk-its/esphome-canopen@dev
|
- source: github://mrk-its/esphome-canopen@canopen_entities
|
||||||
refresh: 1h
|
components: [canopen_entities]
|
||||||
- source: github://mrk-its/esphome-canbus-udp-multicast@dev
|
|
||||||
refresh: 1h
|
refresh: 1h
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
@@ -44,52 +43,22 @@ canopen:
|
|||||||
id: can_open
|
id: can_open
|
||||||
canbus_id: can_bus
|
canbus_id: can_bus
|
||||||
node_id: 1
|
node_id: 1
|
||||||
entities:
|
|
||||||
- index: 1
|
|
||||||
id: light1_state
|
|
||||||
rpdo:
|
|
||||||
- node_id: 2
|
|
||||||
tpdo: 0
|
|
||||||
offset: 0
|
|
||||||
cmd: 0
|
|
||||||
|
|
||||||
- index: 2
|
canopen_entities:
|
||||||
id: light1_brightness
|
remote_nodes:
|
||||||
size: 1
|
node2: mcu-can-node-2.yaml
|
||||||
min_value: 0.0
|
|
||||||
max_value: 1.0
|
|
||||||
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
|
- platform: canopen_entities
|
||||||
id: light1_state
|
id: light1_state
|
||||||
name: Light 1 State
|
name: Light 1 State
|
||||||
- platform: template
|
node: node2
|
||||||
|
entity: light1
|
||||||
|
- platform: canopen_entities
|
||||||
id: light2_state
|
id: light2_state
|
||||||
name: Light 2 State
|
name: Light 2 State
|
||||||
|
node: node2
|
||||||
|
entity: light2
|
||||||
|
|
||||||
- platform: template
|
- platform: template
|
||||||
id: light1_state_cmd
|
id: light1_state_cmd
|
||||||
@@ -105,26 +74,33 @@ binary_sensor:
|
|||||||
pullup: true
|
pullup: true
|
||||||
on_press:
|
on_press:
|
||||||
then:
|
then:
|
||||||
- lambda: |-
|
# both lights on node 2 off if either is on, otherwise both on
|
||||||
bool state = id(light1_state).state || id(light2_state).state;
|
- if:
|
||||||
|
condition:
|
||||||
// send command to entity #1 (light) on node #2
|
lambda: return id(light1_state).state || id(light2_state).state;
|
||||||
id(can_open).send_entity_cmd(2, 1, !state);
|
then:
|
||||||
|
- canopen_entities.light.turn_off: {node: node2, entity: light1}
|
||||||
// send command to entity #2 (light2) on node #2
|
- canopen_entities.light.turn_off: {node: node2, entity: light2}
|
||||||
id(can_open).send_entity_cmd(2, 2, !state);
|
else:
|
||||||
|
- canopen_entities.light.turn_on: {node: node2, entity: light1}
|
||||||
|
- canopen_entities.light.turn_on: {node: node2, entity: light2}
|
||||||
|
|
||||||
sensor:
|
sensor:
|
||||||
- platform: template
|
- platform: canopen_entities
|
||||||
id: light1_brightness
|
id: light1_brightness
|
||||||
name: Light 1 Brightness
|
name: Light 1 Brightness
|
||||||
- platform: template
|
node: node2
|
||||||
|
entity: light1
|
||||||
|
state: brightness
|
||||||
|
- platform: canopen_entities
|
||||||
id: light2_brightness
|
id: light2_brightness
|
||||||
name: Light 2 Brightness
|
name: Light 2 Brightness
|
||||||
|
node: node2
|
||||||
|
entity: light2
|
||||||
|
state: brightness
|
||||||
|
|
||||||
switch:
|
switch:
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
name: LED
|
name: LED
|
||||||
id: blue_led
|
id: blue_led
|
||||||
internal: true
|
|
||||||
pin: 2
|
pin: 2
|
||||||
+4
-3
@@ -28,9 +28,8 @@ esp32:
|
|||||||
type: esp-idf
|
type: esp-idf
|
||||||
|
|
||||||
external_components:
|
external_components:
|
||||||
- source: github://mrk-its/esphome-canopen@dev
|
- source: github://mrk-its/esphome-canopen@canopen_entities
|
||||||
refresh: 1h
|
components: [canopen_entities]
|
||||||
- source: github://mrk-its/esphome-canbus-udp-multicast@dev
|
|
||||||
refresh: 1h
|
refresh: 1h
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
@@ -48,6 +47,8 @@ canopen:
|
|||||||
id: can_open
|
id: can_open
|
||||||
canbus_id: can_bus
|
canbus_id: can_bus
|
||||||
node_id: 2
|
node_id: 2
|
||||||
|
|
||||||
|
canopen_entities:
|
||||||
entities:
|
entities:
|
||||||
- index: 1
|
- index: 1
|
||||||
id: light1
|
id: light1
|
||||||
|
|||||||
Reference in new issue
Block a user