@@ -796,19 +796,9 @@ def scrape_pages(self, response):
796
796
# if self.authErrorFlag != 0:
797
797
# yield {"authErrorFlag": self.authErrorFlag}
798
798
output = {}
799
- for i , div in enumerate (
800
- response .xpath (
801
- '//div[@class="RadPanelBar RadPanelBar_Default rpbSimpleData"]'
802
- )
803
- ):
804
- header_query = (
805
- "//span[@id='ctl00_rdMain_C_controlExtension_rptDisplayContent_ctl0"
806
- + str (i )
807
- + "_ctl00_rpbGroupData_i0_HeaderTemplate_lblHeaderText']/text() "
808
- )
809
- # Catch heading not starting at 0
810
- try :
811
- header = div .xpath (header_query ).extract ()[0 ]
799
+ for div in response .xpath ('//div[contains(@class, "RadPanelBar RadPanelBar_Default rpbSimpleData")]' ):
800
+ header = div .xpath ('.//th[contains(@class, "simpleDataHeaderTextCell")]/span/text()' ).get ()
801
+ if header is not None :
812
802
header = (
813
803
header .replace ("/#" , "" )
814
804
.replace (" " , "" )
@@ -817,63 +807,62 @@ def scrape_pages(self, response):
817
807
.replace (" " , "_" )
818
808
.casefold ()
819
809
)
820
- except IndexError :
810
+ else :
821
811
header = "unknown"
822
812
continue
823
- for td in div .xpath ('.//table[@class= "simpleDataTable"]/ /tr' ):
813
+ for td in div .xpath ('.//div[contains(@class, "rpTemplate")]/ table[contains( @class, "simpleDataTable")]/tbody /tr' ):
824
814
try :
825
- name = td .xpath (
826
- './/td//span[@class="simpleDataName"]/text()'
827
- ).extract ()[0 ]
828
- value = td .xpath (
829
- './/td//span[@class="simpleDataValue"]/text()'
830
- ).extract ()[0 ]
831
- name = name .replace (" " , "" ).replace (" " , "_" ).casefold ()
832
- name = header + "-" + name
833
- split_value = value .split (" " )
834
- unit = ""
835
- if len (split_value ) >= 2 :
836
- value = split_value [0 ]
837
- unit = split_value [1 ]
838
- else :
839
- value = split_value [0 ]
840
- try :
841
- value = "." .join (value .split ("," ))
842
- value = float (value )
843
- except ValueError :
844
- if value in [
845
- "off" ,
846
- "Aus" ,
847
- "--" ,
848
- "Label ist null" ,
849
- "Label ist null " ,
850
- ]:
851
- value = 0.0
852
- elif value in [
853
- "Ein"
854
- ]:
855
- value = 1.0
815
+ name = td .xpath ('.//td[contains(@class, "simpleDataNameCell")]/span/text()' ).get ()
816
+ value = td .xpath ('.//td[contains(@class, "simpleDataValueCell") or contains(@class, "simpleDataValueEnumCell")]/span/text()' ).get ()
817
+ if name is not None and value is not None :
818
+ name = name .replace (" " , "" ).replace (" " , "_" ).casefold ()
819
+ name = header + "-" + name
820
+ split_value = value .split (" " )
821
+ unit = ""
822
+ if len (split_value ) >= 2 :
823
+ value = split_value [0 ]
824
+ unit = split_value [1 ]
856
825
else :
857
- unit = None
858
-
859
- if (name .endswith ('leistungsanforderung' )):
860
- unit = '%'
861
-
862
- icon_mapper = defaultdict (lambda : "mdi:flash" )
863
- icon_mapper ["°C" ] = "mdi:thermometer"
864
-
865
- output [name ] = {
866
- "value" : value ,
867
- "name" : name ,
868
- "icon" : icon_mapper [unit ],
869
- "unit" : unit ,
870
- "platform" : "sensor" ,
871
- "friendlyName" : name ,
872
- "ParameterID" : name ,
873
- }
874
- except IndexError :
826
+ value = split_value [0 ]
827
+ try :
828
+ value = "." .join (value .split ("," ))
829
+ value = float (value )
830
+ except ValueError :
831
+ if value in [
832
+ "off" ,
833
+ "Aus" ,
834
+ "--" ,
835
+ "Label ist null" ,
836
+ "Label ist null " ,
837
+ ]:
838
+ value = 0.0
839
+ elif value in [
840
+ "Ein"
841
+ ]:
842
+ value = 1.0
843
+ else :
844
+ unit = None
845
+
846
+ if (name .endswith ('leistungsanforderung' )):
847
+ unit = '%'
848
+
849
+ icon_mapper = defaultdict (lambda : "mdi:flash" )
850
+ icon_mapper ["°C" ] = "mdi:thermometer"
851
+
852
+ output [name ] = {
853
+ "value" : value ,
854
+ "name" : name ,
855
+ "icon" : icon_mapper [unit ],
856
+ "unit" : unit ,
857
+ "platform" : "sensor" ,
858
+ "friendlyName" : name ,
859
+ "ParameterID" : name ,
860
+ }
861
+ except (IndexError , ValueError ):
875
862
continue
876
863
864
+
877
865
output ["cookie" ] = self .cookie
878
866
879
867
yield output
868
+
0 commit comments