evok-to-mqtt 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/evok-to-mqtt/mappers/to_haab.rb +10 -2
- data/lib/evok-to-mqtt/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: 711e36e73ee487eecfab89bca07163da30c65f3876247b24a911ec8b576f9c92
|
4
|
+
data.tar.gz: edccae5716f33bdd8a3d4fbd69ab8a93a2a966933398fedc40099f7098e3f736
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3f7e1e6ef366f4a4821e627a6b87ee0d8538f8cfb500f237c9d8037bfb2a6bff2582e073c089a1dbc6c7ed165068b2c2bb455345d05679bf330a5ffe5e69d8a
|
7
|
+
data.tar.gz: 11962e6c65f44144fd04e07aa026f67e7a2f77d4ce252da7e51e9e84336ba6ebf40aef4a3e89b8b556e854f53ce4ef578228b1344668ee09787857b1ebf73574
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
1
3
|
module EvokToMqtt
|
2
4
|
module Mappers
|
3
5
|
class ToHaab
|
@@ -11,19 +13,22 @@ module EvokToMqtt
|
|
11
13
|
now = Time.now
|
12
14
|
payload = evok_event
|
13
15
|
|
16
|
+
timestamp = DateTime.now.iso8601(3)
|
17
|
+
|
14
18
|
puts "Target topic: #{id}"
|
15
19
|
|
16
20
|
# Neuron input is assumed for now
|
17
21
|
if @statuses[id]
|
22
|
+
# TODO: input dev only makes sense for this branch
|
18
23
|
if @statuses[id][:value] == 0 && evok_event['value'] == 1
|
19
24
|
#mqtt.publish id, {action: 'down', data: payload}
|
20
25
|
elsif @statuses[id][:value] == 1 && evok_event['value'] == 0
|
21
26
|
#mqtt.publish id, {action: 'up', data: payload}
|
22
27
|
if now - @statuses[id][:changed_at] < 2 # seconds
|
23
|
-
mqtt.publish id, {action: 'click', data: payload}
|
28
|
+
mqtt.publish id, {action: 'click', data: payload, timestamp: timestamp}.to_json
|
24
29
|
puts "### click"
|
25
30
|
else
|
26
|
-
mqtt.publish id, {action: 'long_click', data: payload}
|
31
|
+
mqtt.publish id, {action: 'long_click', data: payload, timestamp: timestamp}.to_json
|
27
32
|
puts "### long_click"
|
28
33
|
end
|
29
34
|
end
|
@@ -33,6 +38,9 @@ module EvokToMqtt
|
|
33
38
|
@statuses[id] = {value: evok_event['value'], changed_at: now}
|
34
39
|
#mqtt.publish id, {action: 'down', data: payload} unless evok_event['value'] == 0 # ignore initial states received in batch
|
35
40
|
end
|
41
|
+
|
42
|
+
mqtt.publish id, {action: 'change', data: payload, timestamp: timestamp}.to_json, retain: true if evok_event['dev'] == 'temp'
|
43
|
+
|
36
44
|
puts
|
37
45
|
end
|
38
46
|
|
data/lib/evok-to-mqtt/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evok-to-mqtt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marek Aufart
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir:
|
10
10
|
- bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-03-
|
12
|
+
date: 2019-03-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: em-mqtt
|