docs: def get_environment(self):
          """Return environment details."""
          environment = junos_views.junos_environment_table(self.device)
          routing_engine = junos_views.junos_routing_engine_table(self.device)
          temperature_thresholds = junos_views.junos_temperature_thresholds(self.device)
          power_supplies = junos_views.junos_pem_table(self.device)
          environment.get()
          routing_engine.get()
          temperature_thresholds.get()
          environment_data = {}
          current_class = None
  
          for sensor_object, object_data in environment.items():
              structured_object_data = {k: v for k, v in object_data}
  
              if structured_object_data["class"]:
                  # If current object has a 'class' defined, store it for use
                  # on subsequent unlabeled lines.
                  current_class = structured_object_data["class"]
              else:
                  # Juniper doesn't label the 2nd+ lines of a given class with a
                  # class name.  In that case, we use the most recent class seen.
                  structured_object_data["class"] = current_class
  
              if structured_object_data["class"] == "Power":
                  # Create a dict for the 'power' key
                  try:
                      environment_data["power"][sensor_object] = {}
                  except KeyError:
                      environment_data["power"] = {}
                      environment_data["power"][sensor_object] = {}
  
                  environment_data["power"][sensor_object]["capacity"] = -1.0
                  environment_data["power"][sensor_object]["output"] = -1.0
  
              if structured_object_data["class"] == "Fans":
                  # Create a dict for the 'fans' key
                  try:
                      environment_data["fans"][sensor_object] = {}
                  except KeyError:
                      environment_data["fans"] = {}
                      environment_data["fans"][sensor_object] = {}
  
              status = structured_object_data["status"]
              env_class = structured_object_data["class"]
              if status == "OK" and env_class == "Power":
                  # If status is Failed, Absent or Testing, set status to False.
                  environment_data["power"][sensor_object]["status"] = True
  
              elif status != "OK" and env_class == "Power":
                  environment_data["power"][sensor_object]["status"] = False
  
              elif status == "OK" and env_class == "Fans":
                  # If status is Failed, Absent or Testing, set status to False.
                  environment_data["fans"][sensor_object]["status"] = True
  
              elif status != "OK" and env_class == "Fans":
                  environment_data["fans"][sensor_object]["status"] = False
  
              for temperature_object, temperature_data in temperature_thresholds.items():
                  structured_temperature_data = {k: v for k, v in temperature_data}
                  if structured_object_data["class"] == "Temp":
                      # Create a dict for the 'temperature' key
                      try:
                          environment_data["temperature"][sensor_object] = {}
                      except KeyError:
                          environment_data["temperature"] = {}
                          environment_data["temperature"][sensor_object] = {}
                      # Check we have a temperature field in this class (See #66)
                      if structured_object_data["temperature"]:
                          environment_data["temperature"][sensor_object][
                              "temperature"
                          ] = float(structured_object_data["temperature"])
                      # Set a default value (False) to the key is_critical and is_alert
                      environment_data["temperature"][sensor_object]["is_alert"] = False
                      environment_data["temperature"][sensor_object][
                          "is_critical"
                      ] = False
                      # Check if the working temperature is equal to or higher than alerting threshold
                      temp = structured_object_data["temperature"]
                      if temp is not None:
                          if structured_temperature_data["red-alarm"] <= temp:
                              environment_data["temperature"][sensor_object][
                                  "is_critical"
                              ] = True
                              environment_data["temperature"][sensor_object][
                                  "is_alert"
                              ] = True
                          elif structured_temperature_data["yellow-alarm"] <= temp:
                              environment_data["temperature"][sensor_object][
                                  "is_alert"
                              ] = True
                      else:
                          environment_data["temperature"][sensor_object][
                              "temperature"
                          ] = 0.0
  
          # Try to correct Power Supply information
          pem_table = dict()
          try:
              power_supplies.get()
          except RpcError:
              # Not all platforms have support for this
              pass
          else:
              # Format PEM information and correct capacity and output values
              if "power" not in environment_data.keys():
                  # Power supplies were not included from the environment table above
                  # Need to initialize data
                  environment_data["power"] = {}
                  for pem in power_supplies.items():
                      pem_name = pem[0].replace("PEM", "Power Supply")
                      environment_data["power"][pem_name] = {}
                      environment_data["power"][pem_name]["output"] = -1.0
                      environment_data["power"][pem_name]["capacity"] = -1.0
                      environment_data["power"][pem_name]["status"] = False
              for pem in power_supplies.items():
                  pem_name = pem[0].replace("PEM", "Power Supply")
                  pem_table[pem_name] = dict(pem[1])
                  if pem_table[pem_name]["capacity"] is not None:
                      environment_data["power"][pem_name]["capacity"] = pem_table[
                          pem_name
                      ]["capacity"]
                  if pem_table[pem_name]["output"] is not None:
                      environment_data["power"][pem_name]["output"] = pem_table[pem_name][
                          "output"
                      ]
                  environment_data["power"][pem_name]["status"] = pem_table[pem_name][
                      "status"
                  ]
  
          for routing_engine_object, routing_engine_data in routing_engine.items():
              structured_routing_engine_data = {k: v for k, v in routing_engine_data}
              # Create dicts for 'cpu' and 'memory'.
              try:
                  environment_data["cpu"][routing_engine_object] = {}
                  environment_data["memory"] = {}
              except KeyError:
                  environment_data["cpu"] = {}
                  environment_data["cpu"][routing_engine_object] = {}
                  environment_data["memory"] = {}
              # Calculate the CPU usage by using the CPU idle value.
              environment_data["cpu"][routing_engine_object]["%usage"] = (
                  100.0 - structured_routing_engine_data["cpu-idle"]
              )
              try:
                  environment_data["memory"]["available_ram"] = int(
                      structured_routing_engine_data["memory-dram-size"]
                  )
              except ValueError:
                  environment_data["memory"]["available_ram"] = int(
                      "".join(
                          i
                          for i in structured_routing_engine_data["memory-dram-size"]
                          if i.isdigit()
                      )
                  )
              # Junos gives us RAM in %, so calculation has to be made.
              # Sadly, bacause of this, results are not 100% accurate to the truth.
              environment_data["memory"]["used_ram"] = int(
                  round(
                      environment_data["memory"]["available_ram"]
                      / 100.0
                      * structured_routing_engine_data["memory-buffer-utilization"]
                  )
              )
  
          return environment_data