somfy_sdn 2.3.1 → 2.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sdn/cli/mqtt/group.rb +9 -1
- data/lib/sdn/cli/mqtt/read.rb +14 -0
- data/lib/sdn/cli/mqtt.rb +76 -0
- data/lib/sdn/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56cba5482b3b557eca27f00d01dc5664f1ec3d38f2392b0dc9433fce98bf1e9f
|
4
|
+
data.tar.gz: e2bdc5db2364b924d2487741351ceed052f89cd8653b1a362f907eae8115160b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66b9d45f728a44d2ad04347110265aa13e515c904735aa874fef32abe1e0c1d5d9e93eff6a91fa27013623ed8607334d03d9d757da485ea231ad4963303726c0
|
7
|
+
data.tar.gz: 75377942f774df2292445cdde5a17891eaca546a6a20bbc899f0fdf3635c46d0e25f71d7807b15bed7c5b2f25638bb78699d43a638a9266ed3c0ce977fd378bb
|
data/lib/sdn/cli/mqtt/group.rb
CHANGED
@@ -3,7 +3,15 @@
|
|
3
3
|
module SDN
|
4
4
|
module CLI
|
5
5
|
class MQTT
|
6
|
-
Group = Struct.new(:bridge,
|
6
|
+
Group = Struct.new(:bridge,
|
7
|
+
:addr,
|
8
|
+
:position_percent,
|
9
|
+
:position_pulses,
|
10
|
+
:ip,
|
11
|
+
:last_direction,
|
12
|
+
:state,
|
13
|
+
:hass_state,
|
14
|
+
:motors) do
|
7
15
|
def initialize(*)
|
8
16
|
members.each { |k| self[k] = :nil }
|
9
17
|
super
|
data/lib/sdn/cli/mqtt/read.rb
CHANGED
@@ -103,6 +103,20 @@ module SDN
|
|
103
103
|
directions = group.motor_objects.map(&:last_direction).uniq
|
104
104
|
direction = (directions.length == 1) ? directions.first : "mixed"
|
105
105
|
group.publish(:last_direction, direction)
|
106
|
+
|
107
|
+
positions = group.motor_objects.map(&:position_percent).uniq
|
108
|
+
position = (positions.length == 1) ? positions.first : 50
|
109
|
+
|
110
|
+
hass_state = if state == :running
|
111
|
+
(direction == :down) ? :closing : :opening
|
112
|
+
elsif position.zero?
|
113
|
+
:open
|
114
|
+
elsif position == 100
|
115
|
+
:closed
|
116
|
+
else
|
117
|
+
:stopped
|
118
|
+
end
|
119
|
+
group.publish(:hass_state, hass_state)
|
106
120
|
end
|
107
121
|
when Message::PostMotorLimits
|
108
122
|
motor.publish(:up_limit, message.up_limit)
|
data/lib/sdn/cli/mqtt.rb
CHANGED
@@ -207,6 +207,7 @@ module SDN
|
|
207
207
|
publish("#{addr}/discover/$format", "discover")
|
208
208
|
publish("#{addr}/discover/$settable", "true")
|
209
209
|
publish("#{addr}/discover/$retained", "false")
|
210
|
+
|
210
211
|
@mqtt.publish_hass_button("discover",
|
211
212
|
command_topic: "#{@base_topic}/#{addr}/discover/set",
|
212
213
|
device: hass_device,
|
@@ -583,6 +584,14 @@ module SDN
|
|
583
584
|
return group if group
|
584
585
|
|
585
586
|
@mqtt.batch_publish do
|
587
|
+
hass_device = {
|
588
|
+
identifiers: addr,
|
589
|
+
model: "Shade Group",
|
590
|
+
name: addr,
|
591
|
+
via_device: @device_id
|
592
|
+
}
|
593
|
+
node_id = "#{@device_id}_#{addr}"
|
594
|
+
|
586
595
|
publish("#{addr}/$name", addr)
|
587
596
|
publish("#{addr}/$type", "Shade Group")
|
588
597
|
publish("#{addr}/$properties",
|
@@ -595,12 +604,53 @@ module SDN
|
|
595
604
|
publish("#{addr}/discover/$settable", "true")
|
596
605
|
publish("#{addr}/discover/$retained", "false")
|
597
606
|
|
607
|
+
@mqtt.publish_hass_button("discover",
|
608
|
+
command_topic: "#{@base_topic}/#{addr}/discover/set",
|
609
|
+
device: hass_device,
|
610
|
+
icon: "mdi:search-add",
|
611
|
+
name: "Rediscover",
|
612
|
+
node_id: node_id,
|
613
|
+
object_id: "discover",
|
614
|
+
payload_press: "discover",
|
615
|
+
unique_id: "#{node_id}_discover")
|
616
|
+
|
598
617
|
publish("#{addr}/control/$name", "Control motors")
|
599
618
|
publish("#{addr}/control/$datatype", "enum")
|
600
619
|
publish("#{addr}/control/$format", "up,down,stop,wink,next_ip,previous_ip,refresh")
|
601
620
|
publish("#{addr}/control/$settable", "true")
|
602
621
|
publish("#{addr}/control/$retained", "false")
|
603
622
|
|
623
|
+
@mqtt.publish_hass_cover("group",
|
624
|
+
command_topic: "#{@base_topic}/#{addr}/control/set",
|
625
|
+
device: hass_device,
|
626
|
+
icon: "mdi:roller-shade",
|
627
|
+
name: "Group",
|
628
|
+
node_id: node_id,
|
629
|
+
payload_close: "down",
|
630
|
+
payload_open: "up",
|
631
|
+
payload_stop: "stop",
|
632
|
+
position_open: 0,
|
633
|
+
position_closed: 100,
|
634
|
+
position_topic: "#{@base_topic}/#{addr}/position-percent",
|
635
|
+
set_position_topic: "#{@base_topic}/#{addr}/position-percent/set",
|
636
|
+
state_topic: "#{@base_topic}/#{addr}/hass-state",
|
637
|
+
unique_id: "#{node_id}_group")
|
638
|
+
{
|
639
|
+
Wink: "mdi:emoticon-wink",
|
640
|
+
Next_IP: "mdi:skip-next",
|
641
|
+
Previous_IP: "mdi:skip-previous",
|
642
|
+
Refresh: "mdi:refresh"
|
643
|
+
}.each do |command, icon|
|
644
|
+
@mqtt.publish_hass_button(command.to_s.downcase,
|
645
|
+
command_topic: "#{@base_topic}/#{addr}/control/set",
|
646
|
+
device: hass_device,
|
647
|
+
icon: icon,
|
648
|
+
name: command.to_s.sub("_", " "),
|
649
|
+
node_id: node_id,
|
650
|
+
payload_press: command.to_s.downcase,
|
651
|
+
unique_id: "#{node_id}_#{command.to_s.downcase}")
|
652
|
+
end
|
653
|
+
|
604
654
|
publish("#{addr}/jog-ms/$name", "Jog motors by ms")
|
605
655
|
publish("#{addr}/jog-ms/$datatype", "integer")
|
606
656
|
publish("#{addr}/jog-ms/$format", "-65535:65535")
|
@@ -621,6 +671,20 @@ module SDN
|
|
621
671
|
publish("#{addr}/position-pulses/$unit", "pulses")
|
622
672
|
publish("#{addr}/position-pulses/$settable", "true")
|
623
673
|
|
674
|
+
@mqtt.publish_hass_number("position-pulses",
|
675
|
+
command_topic: "#{@base_topic}/#{addr}/position-pulses/set",
|
676
|
+
device: hass_device,
|
677
|
+
enabled_by_default: false,
|
678
|
+
max: 65_536,
|
679
|
+
min: 0,
|
680
|
+
name: "Position (Pulses)",
|
681
|
+
node_id: node_id,
|
682
|
+
object_id: "position-pulses",
|
683
|
+
state_topic: "#{@base_topic}/#{addr}/position-pulses",
|
684
|
+
step: 10,
|
685
|
+
unit_of_measurement: "pulses",
|
686
|
+
unique_id: "#{node_id}_position-pulses")
|
687
|
+
|
624
688
|
publish("#{addr}/position-percent/$name", "Position (in %)")
|
625
689
|
publish("#{addr}/position-percent/$datatype", "integer")
|
626
690
|
publish("#{addr}/position-percent/$format", "0:100")
|
@@ -632,6 +696,18 @@ module SDN
|
|
632
696
|
publish("#{addr}/ip/$format", "1:16")
|
633
697
|
publish("#{addr}/ip/$settable", "true")
|
634
698
|
|
699
|
+
@mqtt.publish_hass_number("ip",
|
700
|
+
command_topic: "#{@base_topic}/#{addr}/ip/set",
|
701
|
+
device: hass_device,
|
702
|
+
name: "Intermediate Position",
|
703
|
+
max: 16,
|
704
|
+
min: 0,
|
705
|
+
node_id: node_id,
|
706
|
+
object_id: "ip",
|
707
|
+
payload_reset: "",
|
708
|
+
state_topic: "#{@base_topic}/#{addr}/ip",
|
709
|
+
unique_id: "#{node_id}_ip")
|
710
|
+
|
635
711
|
publish("#{addr}/state/$name", "State of the motors")
|
636
712
|
publish("#{addr}/state/$datatype", "enum")
|
637
713
|
publish("#{addr}/state/$format", "#{Message::PostMotorStatus::STATE.keys.join(",")},mixed")
|
data/lib/sdn/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: somfy_sdn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cody Cutrer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-01-
|
11
|
+
date: 2025-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ccutrer-serialport
|