Kaynağa Gözat

device: brightness and color temperature calculations corrected

tags/v1.0.0
Dirk Alders 1 yıl önce
ebeveyn
işleme
f86ad1813c
1 değiştirilmiş dosya ile 4 ekleme ve 178 silme
  1. 4
    178
      devices/__init__.py

+ 4
- 178
devices/__init__.py Dosyayı Görüntüle

@@ -580,17 +580,17 @@ class tradfri_light(base):
580 580
 
581 581
     def unpack_filter(self, key):
582 582
         if key == self.KEY_BRIGHTNESS:
583
-            self[key] = (self[key] - 1) * 100 / 254
583
+            self[key] = round((self[key] - 1) * 100 / 253, 0)
584 584
         elif key == self.KEY_COLOR_TEMP:
585
-            self[key] = (self[key] - 250) * 10 / 204
585
+            self[key] = round((self[key] - 250) * 10 / 204, 0)
586 586
         else:
587 587
             super().unpack_filter(key)
588 588
 
589 589
     def pack_filter(self, key, data):
590 590
         if key == self.KEY_BRIGHTNESS:
591
-            return data * 254 / 100 + 1
591
+            return round(data * 253 / 100 + 1, 0)
592 592
         elif key == self.KEY_COLOR_TEMP:
593
-            return data * 204 / 10 + 250
593
+            return round(data * 204 / 10 + 250, 0)
594 594
         else:
595 595
             return super().pack_filter(key, data)
596 596
 
@@ -708,180 +708,6 @@ class tradfri_button(base):
708 708
         return "Low battery level detected for %s. Battery level was %.0f%%." % (self.topic, self.get(self.KEY_BATTERY))
709 709
 
710 710
 
711
-class nodered_gui_leds(base):
712
-    KEY_LED_0 = "led0"
713
-    KEY_LED_1 = "led1"
714
-    KEY_LED_2 = "led2"
715
-    KEY_LED_3 = "led3"
716
-    KEY_LED_4 = "led4"
717
-    KEY_LED_5 = "led5"
718
-    KEY_LED_6 = "led6"
719
-    KEY_LED_7 = "led7"
720
-    KEY_LED_8 = "led8"
721
-    KEY_LED_9 = "led9"
722
-    KEY_LED_LIST = [KEY_LED_0, KEY_LED_1, KEY_LED_2, KEY_LED_3, KEY_LED_4, KEY_LED_5, KEY_LED_6, KEY_LED_7, KEY_LED_8, KEY_LED_9]
723
-    #
724
-    TX_TYPE = base.TX_VALUE
725
-
726
-    def set_led(self, key, data):
727
-        """data: [True, False]"""
728
-        self.logger.debug("Sending %s with content %s", key, str(data))
729
-        self.pack(key, data)
730
-
731
-
732
-class nodered_gui_timer(base):
733
-    KEY_TIMER = "timer"
734
-    #
735
-    TX_TYPE = base.TX_VALUE
736
-
737
-    def set_timer(self, data):
738
-        """data: numeric"""
739
-        self.pack(self.KEY_TIMER, data)
740
-
741
-    def set_timer_mcb(self, device, key, data):
742
-        self.logger.debug("Sending %s with content %s", key, str(data))
743
-        self.set_timer(data)
744
-
745
-
746
-class nodered_gui_button(base):
747
-    KEY_STATE = "state"
748
-    #
749
-    RX_KEYS = [KEY_STATE]
750
-
751
-    #
752
-    # RX
753
-    #
754
-    @property
755
-    def state(self):
756
-        """rv: [True, False]"""
757
-        return self.get(self.KEY_STATE)
758
-
759
-
760
-class nodered_gui_switch(nodered_gui_button):
761
-    TX_TYPE = base.TX_VALUE
762
-
763
-    #
764
-    # TX
765
-    #
766
-    def set_state(self, data):
767
-        """data: [True, False]"""
768
-        self.pack(self.KEY_STATE, data)
769
-
770
-    def set_state_mcb(self, device, key, data):
771
-        self.logger.debug("Sending %s with content %s", key, str(data))
772
-        self.set_state(data)
773
-
774
-
775
-class nodered_gui_light(nodered_gui_switch, nodered_gui_leds, nodered_gui_timer):
776
-    KEY_ENABLE = "enable"
777
-    KEY_BRIGHTNESS = "brightness"
778
-    KEY_COLOR_TEMP = "color_temp"
779
-    #
780
-    TX_TYPE = base.TX_VALUE
781
-    #
782
-    RX_KEYS = nodered_gui_switch.RX_KEYS + [KEY_ENABLE, KEY_BRIGHTNESS, KEY_COLOR_TEMP]
783
-
784
-    #
785
-    # RX
786
-    #
787
-    @property
788
-    def enable(self):
789
-        """rv: [True, False]"""
790
-        return self.get(self.KEY_ENABLE)
791
-
792
-    @property
793
-    def brightness(self):
794
-        """rv: [True, False]"""
795
-        return self.get(self.KEY_BRIGHTNESS)
796
-
797
-    @property
798
-    def color_temp(self):
799
-        """rv: [True, False]"""
800
-        return self.get(self.KEY_COLOR_TEMP)
801
-
802
-    #
803
-    # TX
804
-    #
805
-    def set_enable(self, data):
806
-        """data: [True, False]"""
807
-        self.pack(self.KEY_ENABLE, data)
808
-
809
-    def set_enable_mcb(self, device, key, data):
810
-        self.logger.debug("Sending %s with content %s", key, str(data))
811
-        self.set_enable(data)
812
-
813
-    def set_brightness(self, data):
814
-        """data: [0%, ..., 100%]"""
815
-        self.pack(self.KEY_BRIGHTNESS, data)
816
-
817
-    def set_brightness_mcb(self, device, key, data):
818
-        self.logger.debug("Sending %s with content %s", key, str(data))
819
-        self.set_brightness(data)
820
-
821
-    def set_color_temp(self, data):
822
-        """data: [0, ..., 10]"""
823
-        self.pack(self.KEY_COLOR_TEMP, data)
824
-
825
-    def set_color_temp_mcb(self, device, key, data):
826
-        self.logger.debug("Sending %s with content %s", key, str(data))
827
-        self.set_color_temp(data)
828
-
829
-
830
-class nodered_gui_radiator(nodered_gui_timer):
831
-    KEY_TEMPERATURE = "temperature"
832
-    KEY_SETPOINT_TEMP = "setpoint_temp"
833
-    KEY_SETPOINT_TO_DEFAULT = "setpoint_to_default"
834
-    KEY_BOOST = 'boost'
835
-    KEY_AWAY = "away"
836
-    KEY_SUMMER = "summer"
837
-    KEY_ENABLE = "enable"
838
-    #
839
-    RX_KEYS = [KEY_TEMPERATURE, KEY_SETPOINT_TEMP, KEY_SETPOINT_TO_DEFAULT, KEY_BOOST, KEY_AWAY, KEY_SUMMER]
840
-
841
-    #
842
-    # TX
843
-    #
844
-    def set_temperature(self, data):
845
-        """data: [True, False]"""
846
-        self.pack(self.KEY_TEMPERATURE, data)
847
-
848
-    def set_temperature_mcb(self, device, key, data):
849
-        self.logger.debug("Sending %s with content %s", key, str(data))
850
-        self.set_temperature(data)
851
-
852
-    def set_setpoint_temperature(self, data):
853
-        """data: [True, False]"""
854
-        self.pack(self.KEY_SETPOINT_TEMP, data)
855
-
856
-    def set_setpoint_temperature_mcb(self, device, key, data):
857
-        self.logger.debug("Sending %s with content %s", key, str(data))
858
-        self.set_setpoint_temperature(data)
859
-
860
-    def set_away(self, data):
861
-        """data: [True, False]"""
862
-        self.pack(self.KEY_AWAY, data)
863
-
864
-    def set_away_mcb(self, device, key, data):
865
-        self.logger.debug("Sending %s with content %s", key, str(data))
866
-        self.set_away(data)
867
-
868
-    def set_summer(self, data):
869
-        """data: [True, False]"""
870
-        self.pack(self.KEY_SUMMER, data)
871
-
872
-    def set_summer_mcb(self, device, key, data):
873
-        self.logger.debug("Sending %s with content %s", key, str(data))
874
-        self.set_summer(data)
875
-
876
-    def set_enable(self, data):
877
-        """data: [True, False]"""
878
-        self.pack(self.KEY_ENABLE, data)
879
-
880
-    def set_enable_mcb(self, device, key, data):
881
-        self.logger.debug("Sending %s with content %s", key, str(data))
882
-        self.set_enable(data)
883
-
884
-
885 711
 class brennenstuhl_heatingvalve(base):
886 712
     KEY_LINKQUALITY = "linkquality"
887 713
     KEY_BATTERY = "battery"

Loading…
İptal
Kaydet