Commit 4b1d0dd1 authored by Martin Pollet's avatar Martin Pollet

Detect ShellyDimmer with URL /lights, closed #43

parent 71e93548
Pipeline #164 passed with stage
in 4 minutes and 55 seconds
......@@ -116,25 +116,26 @@
(reg-event-db
:switches-init
(fn [db [_ shelly settings]]
(fn [db [_ shelly status]]
(let [id (:id shelly)]
(cond
(cond
; RGB & Bulb: white mode
(when-let [lights (:lights settings)] (and (shelly/has-brightness? (first lights))
(= "white" (:mode (first lights)))))
(get-switches db id "white" (:lights settings)) ;min value for color temp for Bulb (will not affect others)
(when-let [lights (:lights status)] (and (shelly/has-brightness? (first lights))
(= "white" (:mode (first lights)))
(not (contains? status :calib_progress)))) ; not Dimmer
(get-switches db id "white" (:lights status)) ;min value for color temp for Bulb (will not affect others)
; RGB & Bulb: color mode
(when-let [lights (:lights settings)] (shelly/has-colors? (first lights)))
(get-switches db id "color" (:lights settings))
(when-let [lights (:lights status)] (shelly/has-colors? (first lights)))
(get-switches db id "color" (:lights status))
; Vintage & Dimmer & Duo
(when-let [lights (:lights settings)] (shelly/has-brightness? (first lights)))
(get-switches db id "light" (:lights settings))
(when-let [lights (:lights status)] (shelly/has-brightness? (first lights)))
(get-switches db id "light" (:lights status))
; Shelly 1 & 1pm & 2.5 relay-mode & Plug(S)
(:relays settings) (get-switches db id "relay" (:relays settings))
(:relays status) (get-switches db id "relay" (:relays status))
; 2.5 roller shutter mode
(:rollers settings) (get-switches db id "roller" (:rollers settings))
(:rollers status) (get-switches db id "roller" (:rollers status))
;
:else (do (println "unknown mode" settings) db)))))
:else (do (println "unknown mode" status) db)))))
(reg-event-db
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment