How to use property_values method in Selene

Best Python code snippet using selene_python

installation.py

Source:installation.py Github

copy

Full Screen

1from enum import Flag, auto2class PropertyCategory(Flag):3 INVERTER_STATE = auto()4 PV_POWER = auto()5 PV_ENERGY_STATS = auto()6 GRID_POWER = auto()7 GRID_ENERGY_STATS = auto()8 OUTPUT_POWER = auto()9 OUTPUT_ENERGY_STATS = auto()10 BATTERY_POWER = auto()11 BATTERY_VOLTAGE = auto()12 BATTERY_CURRENT = auto()13 BATTERY_CHARGE = auto()14 BATTERY_TEMPERATURE = auto()15 BATTERY_ENERGY_STATS = auto()16class Installation:17 def __init__(self, device_access_id, inverter_count, solar_charger_count, battery_count):18 self.device_access_id = device_access_id19 self.inverter_count = inverter_count20 self.solar_charger_count = solar_charger_count21 self.battery_count = battery_count22 self.property_values = {}23 def get_property_ids(self, categories):24 return []25 def set_property_value(self, property_id, value):26 self.property_values[property_id] = value27 def inverter_get_state(self):28 return False29 def inverter_turn_on(self, client):30 pass31 def inverter_turn_off(self, client):32 pass33 def pv_get_power(self):34 return None35 def pv_get_energy_today(self):36 return None37 def pv_get_energy_yesterday(self):38 return None39 def grid_get_power(self):40 return None41 def grid_get_energy_today(self):42 return None43 def grid_get_energy_yesterday(self):44 return None45 def output_get_power(self):46 return None47 def output_get_energy_today(self):48 return None49 def output_get_energy_yesterday(self):50 return None51 def battery_get_power(self):52 return None53 def battery_get_voltage(self):54 return None55 def battery_get_current(self):56 return None57 def battery_get_charge(self):58 return None59 def battery_get_temperature(self):60 return None61 def battery_get_charge_today(self):62 return None63 def battery_get_charge_yesterday(self):64 return None65 def battery_get_discharge_today(self):66 return None67 def battery_get_discharge_yesterday(self):68 return None69class Xcom485IInstallation(Installation):70 def __init__(self, device_access_id, devices):71 self.__xtender_ids = []72 self.__variotrack_ids = []73 self.__variostring_ids = []74 self.__battery_id = None75 for device in devices:76 id_ = device['id']77 if id_.startswith('xt') and id_ != 'xts':78 self.__xtender_ids.append(id_)79 if id_.startswith('vt') and id_ != 'vts':80 self.__variotrack_ids.append(id_)81 if id_.startswith('vs') and id_ != 'vss':82 self.__variostring_ids.append(id_)83 if id_ == 'bat':84 self.__battery_id = id_85 super(Xcom485IInstallation, self).__init__(device_access_id, len(self.__xtender_ids), len(self.__variotrack_ids) + len(self.__variostring_ids),86 1 if self.__battery_id is not None else 0)87 def get_property_ids(self, categories):88 ids = []89 if categories & PropertyCategory.INVERTER_STATE:90 ids += [f'{self.device_access_id}.xts.3049']91 if categories & PropertyCategory.PV_POWER:92 for vt_id in self.__variotrack_ids:93 ids.append(f'{self.device_access_id}.{vt_id}.11004')94 for vs_id in self.__variostring_ids:95 ids.append(f'{self.device_access_id}.{vs_id}.15010')96 if categories & PropertyCategory.PV_ENERGY_STATS:97 for vt_id in self.__variotrack_ids:98 ids.append(f'{self.device_access_id}.{vt_id}.11007')99 ids.append(f'{self.device_access_id}.{vt_id}.11011')100 for vs_id in self.__variostring_ids:101 ids.append(f'{self.device_access_id}.{vs_id}.15017')102 ids.append(f'{self.device_access_id}.{vs_id}.15027')103 if categories & PropertyCategory.GRID_POWER:104 for xt_id in self.__xtender_ids:105 ids.append(f'{self.device_access_id}.{xt_id}.3137')106 if categories & PropertyCategory.GRID_ENERGY_STATS:107 for xt_id in self.__xtender_ids:108 ids.append(f'{self.device_access_id}.{xt_id}.3081')109 ids.append(f'{self.device_access_id}.{xt_id}.3080')110 if categories & PropertyCategory.OUTPUT_POWER:111 for xt_id in self.__xtender_ids:112 ids.append(f'{self.device_access_id}.{xt_id}.3136')113 if categories & PropertyCategory.OUTPUT_ENERGY_STATS:114 for xt_id in self.__xtender_ids:115 ids.append(f'{self.device_access_id}.{xt_id}.3083')116 ids.append(f'{self.device_access_id}.{xt_id}.3082')117 if categories & PropertyCategory.BATTERY_POWER:118 ids += [f'{self.device_access_id}.bat.7003']119 if categories & PropertyCategory.BATTERY_VOLTAGE:120 ids += [f'{self.device_access_id}.bat.7000']121 if categories & PropertyCategory.BATTERY_CURRENT:122 ids += [f'{self.device_access_id}.bat.7001']123 if categories & PropertyCategory.BATTERY_CHARGE:124 ids += [f'{self.device_access_id}.bat.7002']125 if categories & PropertyCategory.BATTERY_TEMPERATURE:126 ids += [f'{self.device_access_id}.bat.7033']127 if categories & PropertyCategory.BATTERY_ENERGY_STATS:128 ids += [f'{self.device_access_id}.bat.7007', f'{self.device_access_id}.bat.7008', f'{self.device_access_id}.bat.7009', f'{self.device_access_id}.bat.7010']129 return ids130 def inverter_get_state(self):131 return self.property_values[f'{self.device_access_id}.xts.3049'] == 1.0132 def inverter_turn_on(self, client):133 client.write_property(f'{self.device_access_id}.xts.1415')134 def inverter_turn_off(self, client):135 client.write_property(f'{self.device_access_id}.xts.1399')136 def pv_get_power(self):137 power = 0138 for key, value in self.property_values.items():139 if key.endswith('.11004') or key.endswith('.15010'):140 power += value141 return power142 def pv_get_energy_today(self):143 energy = 0144 for key, value in self.property_values.items():145 if key.endswith('.11007') or key.endswith('.15017'):146 energy += value147 return energy148 def pv_get_energy_yesterday(self):149 energy = 0150 for key, value in self.property_values.items():151 if key.endswith('.11011') or key.endswith('.15027'):152 energy += value153 return energy154 def grid_get_power(self):155 power = 0156 for key, value in self.property_values.items():157 if key.endswith('.3137'):158 power += value159 return power160 def grid_get_energy_today(self):161 energy = 0162 for key, value in self.property_values.items():163 if key.endswith('.3081'):164 energy += value165 return energy166 def grid_get_energy_yesterday(self):167 energy = 0168 for key, value in self.property_values.items():169 if key.endswith('.3080'):170 energy += value171 return energy172 def output_get_power(self):173 power = 0174 for key, value in self.property_values.items():175 if key.endswith('.3136'):176 power += value177 return power178 def output_get_energy_today(self):179 energy = 0180 for key, value in self.property_values.items():181 if key.endswith('.3083'):182 energy += value183 return energy184 def output_get_energy_yesterday(self):185 energy = 0186 for key, value in self.property_values.items():187 if key.endswith('.3082'):188 energy += value189 return energy190 def battery_get_power(self):191 return self.property_values[f'{self.device_access_id}.bat.7003']192 def battery_get_voltage(self):193 return self.property_values[f'{self.device_access_id}.bat.7000']194 def battery_get_current(self):195 return self.property_values[f'{self.device_access_id}.bat.7001']196 def battery_get_charge(self):197 return self.property_values[f'{self.device_access_id}.bat.7002']198 def battery_get_temperature(self):199 return self.property_values[f'{self.device_access_id}.bat.7033']200 def battery_get_charge_today(self):201 return self.property_values[f'{self.device_access_id}.bat.7007']202 def battery_get_charge_yesterday(self):203 return self.property_values[f'{self.device_access_id}.bat.7009']204 def battery_get_discharge_today(self):205 return self.property_values[f'{self.device_access_id}.bat.7008']206 def battery_get_discharge_yesterday(self):207 return self.property_values[f'{self.device_access_id}.bat.7010']208class DemoInstallation(Installation):209 def __init__(self, device_access_id):210 super(DemoInstallation, self).__init__(device_access_id, 1, 1, 1)211 def get_property_ids(self, categories):212 ids = []213 if categories & PropertyCategory.INVERTER_STATE:214 ids += [f'{self.device_access_id}.inv.3049']215 if categories & PropertyCategory.PV_POWER:216 ids += [f'{self.device_access_id}.sol.11004']217 if categories & PropertyCategory.PV_ENERGY_STATS:218 ids += [f'{self.device_access_id}.sol.11007', f'{self.device_access_id}.sol.11011']219 if categories & PropertyCategory.GRID_POWER:220 ids += [f'{self.device_access_id}.inv.3137']221 if categories & PropertyCategory.GRID_ENERGY_STATS:222 ids += [f'{self.device_access_id}.inv.3081', f'{self.device_access_id}.inv.3080']223 if categories & PropertyCategory.OUTPUT_POWER:224 ids += [f'{self.device_access_id}.inv.3136']225 if categories & PropertyCategory.OUTPUT_ENERGY_STATS:226 ids += [f'{self.device_access_id}.inv.3083', f'{self.device_access_id}.inv.3082']227 if categories & PropertyCategory.BATTERY_POWER:228 ids += [f'{self.device_access_id}.bat.7003']229 if categories & PropertyCategory.BATTERY_VOLTAGE:230 ids += [f'{self.device_access_id}.bat.7000']231 if categories & PropertyCategory.BATTERY_CURRENT:232 ids += [f'{self.device_access_id}.bat.7001']233 if categories & PropertyCategory.BATTERY_CHARGE:234 ids += [f'{self.device_access_id}.bat.7002']235 if categories & PropertyCategory.BATTERY_TEMPERATURE:236 ids += [f'{self.device_access_id}.bat.7033']237 if categories & PropertyCategory.BATTERY_ENERGY_STATS:238 ids += [f'{self.device_access_id}.bat.7007', f'{self.device_access_id}.bat.7008', f'{self.device_access_id}.bat.7009', f'{self.device_access_id}.bat.7010']239 return ids240 def inverter_get_state(self):241 return self.property_values[f'{self.device_access_id}.inv.3049'] == 1.0242 def inverter_turn_on(self, client):243 client.write_property(f'{self.device_access_id}.inv.1415')244 def inverter_turn_off(self, client):245 client.write_property(f'{self.device_access_id}.inv.1399')246 def pv_get_power(self):247 return self.property_values[f'{self.device_access_id}.sol.11004']248 def pv_get_energy_today(self):249 return self.property_values[f'{self.device_access_id}.sol.11007']250 def pv_get_energy_yesterday(self):251 return self.property_values[f'{self.device_access_id}.sol.11011']252 def grid_get_power(self):253 return self.property_values[f'{self.device_access_id}.inv.3137']254 def grid_get_energy_today(self):255 return self.property_values[f'{self.device_access_id}.inv.3081']256 def grid_get_energy_yesterday(self):257 return self.property_values[f'{self.device_access_id}.inv.3080']258 def output_get_power(self):259 return self.property_values[f'{self.device_access_id}.inv.3136']260 def output_get_energy_today(self):261 return self.property_values[f'{self.device_access_id}.inv.3083']262 def output_get_energy_yesterday(self):263 return self.property_values[f'{self.device_access_id}.inv.3082']264 def battery_get_power(self):265 return self.property_values[f'{self.device_access_id}.bat.7003']266 def battery_get_voltage(self):267 return self.property_values[f'{self.device_access_id}.bat.7000']268 def battery_get_current(self):269 return self.property_values[f'{self.device_access_id}.bat.7001']270 def battery_get_charge(self):271 return self.property_values[f'{self.device_access_id}.bat.7002']272 def battery_get_temperature(self):273 return self.property_values[f'{self.device_access_id}.bat.7033']274 def battery_get_charge_today(self):275 return self.property_values[f'{self.device_access_id}.bat.7007']276 def battery_get_charge_yesterday(self):277 return self.property_values[f'{self.device_access_id}.bat.7009']278 def battery_get_discharge_today(self):279 return self.property_values[f'{self.device_access_id}.bat.7008']280 def battery_get_discharge_yesterday(self):...

Full Screen

Full Screen

helpers.py

Source:helpers.py Github

copy

Full Screen

1"""2Helpers module conatains helper function to extract description, metadata,3outputs, resources from the cloudformation template file content.4"""5from troposphere import Ref, Output, ec26def get_description(data):7 """Gets description from the input cloutformation file content."""8 return data['Description']9def get_metadata(data):10 """Gets metadata from the input cloutformation file content."""11 return data['Metadata']12def get_outputs(data):13 """Gets outputs from the input cloutformation file content."""14 outputs = data['Outputs']15 return [16 Output(output_name, Value=Ref(output_values['Value']['Ref']))17 for output_name, output_values in outputs.items()18 ]19def get_resources(data):20 """Gets resources from the input cloutformation file content."""21 return data['Resources']22def get_resource_type_name(resource_values):23 """Gets resource type name from resource values."""24 resource_type = resource_values['Type']25 return resource_type.split('::')[-1]26def get_property(property_name, property_values):27 """28 Gets property from property_name and property_values which troposphere29 supports.30 """31 if isinstance(property_values, int):32 data = {property_name: str(property_values)}33 elif 'Ref' in property_values:34 data = {property_name: Ref(property_values['Ref'])}35 elif 'PortRange' in property_name:36 data = {property_name: ec2.PortRange(**property_values)}37 else:38 data = {property_name: property_values}39 return data40def get_properties(resource_values):41 """Gets the properties from resource values."""42 properties = {}43 properties_data = resource_values['Properties']44 for property_name, property_values in properties_data.items():45 properties.update(46 get_property(property_name, property_values)47 )...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Selene automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful