somfy_sdn 2.3.1 → 2.3.2
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 +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9d3b292843473f2020321bca2d00cef41b0a1374cf9df8a5f99e8c3f699dfb0
|
4
|
+
data.tar.gz: eb2cb0abbbcff66897e815ce8e97928af0b9dd598d464efe12b99bee3ed646d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48a69e210eaccaf15de99cd35b499547208b9a05bd30ed2796617b34dbbabaf9d2f11be87e09dd6dce7a5a618d5e5232d6420a6903c4c007f6ce3bba9ac214ab
|
7
|
+
data.tar.gz: fe5e5215cb3f870b1b36e926546260234cd4dbbce2985b77cdc2bfaac4c89c9672ef0a05748726a1e4869ef6b73fa6c839dfce8a3b9ff2cbd67926c20062c892
|
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: "true",
|
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