Set nest entities as unavailable on lost connection
diff --git a/homeassistant/components/nest/climate_sdm.py b/homeassistant/components/nest/climate_sdm.py
index e40db60d5eddab..3113cb2dd40201 100644
--- a/homeassistant/components/nest/climate_sdm.py
+++ b/homeassistant/components/nest/climate_sdm.py
@@ -117,6 +117,11 @@ def device_info(self) -> DeviceInfo:
         """Return device specific attributes."""
         return self._device_info.device_info
 
+    @property
+    def available(self) -> bool:
+        """Return device availability."""
+        return self._device_info.available
+
     async def async_added_to_hass(self) -> None:
         """Run when entity is added to register update signal handler."""
         self._attr_supported_features = self._get_supported_features()
diff --git a/homeassistant/components/nest/const.py b/homeassistant/components/nest/const.py
index 64c27c1643be78..853e778977d35a 100644
--- a/homeassistant/components/nest/const.py
+++ b/homeassistant/components/nest/const.py
@@ -14,6 +14,8 @@
 CONF_SUBSCRIBER_ID_IMPORTED = "subscriber_id_imported"
 CONF_CLOUD_PROJECT_ID = "cloud_project_id"
 
+CONNECTIVITY_TRAIT_OFFLINE = "OFFLINE"
+
 SIGNAL_NEST_UPDATE = "nest_update"
 
 # For the Google Nest Device Access API
diff --git a/homeassistant/components/nest/device_info.py b/homeassistant/components/nest/device_info.py
index 2d2b01d3849255..e269b76fcc4be5 100644
--- a/homeassistant/components/nest/device_info.py
+++ b/homeassistant/components/nest/device_info.py
@@ -5,13 +5,13 @@
 from collections.abc import Mapping
 
 from google_nest_sdm.device import Device
-from google_nest_sdm.device_traits import InfoTrait
+from google_nest_sdm.device_traits import ConnectivityTrait, InfoTrait
 
 from homeassistant.core import HomeAssistant, callback
 from homeassistant.helpers import device_registry as dr
 from homeassistant.helpers.entity import DeviceInfo
 
-from .const import DATA_DEVICE_MANAGER, DOMAIN
+from .const import CONNECTIVITY_TRAIT_OFFLINE, DATA_DEVICE_MANAGER, DOMAIN
 
 DEVICE_TYPE_MAP: dict[str, str] = {
     "sdm.devices.types.CAMERA": "Camera",
@@ -30,6 +30,15 @@ def __init__(self, device: Device) -> None:
         """Initialize the DeviceInfo."""
         self._device = device
 
+    @property
+    def available(self) -> bool:
+        """Return device availability."""
+        if ConnectivityTrait.NAME in self._device.traits:
+            trait: ConnectivityTrait = self._device.traits[ConnectivityTrait.NAME]
+            if trait.status == CONNECTIVITY_TRAIT_OFFLINE:
+                return False
+        return True
+
     @property
     def device_info(self) -> DeviceInfo:
         """Return device specific attributes."""
diff --git a/homeassistant/components/nest/sensor_sdm.py b/homeassistant/components/nest/sensor_sdm.py
index 11edc9f3506fc3..b36e91031960ff 100644
--- a/homeassistant/components/nest/sensor_sdm.py
+++ b/homeassistant/components/nest/sensor_sdm.py
@@ -62,6 +62,11 @@ def __init__(self, device: Device) -> None:
         self._attr_unique_id = f"{device.name}-{self.device_class}"
         self._attr_device_info = self._device_info.device_info
 
+    @property
+    def available(self) -> bool:
+        """Return the device availability."""
+        return self._device_info.available
+
     async def async_added_to_hass(self) -> None:
         """Run when entity is added to register update signal handler."""
         self.async_on_remove(
diff --git a/tests/components/nest/test_climate_sdm.py b/tests/components/nest/test_climate_sdm.py
index 440855f6ab7782..4ac58171fcdcd7 100644
--- a/tests/components/nest/test_climate_sdm.py
+++ b/tests/components/nest/test_climate_sdm.py
@@ -34,7 +34,11 @@
     HVACAction,
     HVACMode,
 )
-from homeassistant.const import ATTR_SUPPORTED_FEATURES, ATTR_TEMPERATURE
+from homeassistant.const import (
+    ATTR_SUPPORTED_FEATURES,
+    ATTR_TEMPERATURE,
+    STATE_UNAVAILABLE,
+)
 from homeassistant.core import HomeAssistant
 from homeassistant.exceptions import HomeAssistantError
 
@@ -1442,3 +1446,63 @@ async def test_thermostat_hvac_mode_failure(
     with pytest.raises(HomeAssistantError):
         await common.async_set_preset_mode(hass, PRESET_ECO)
         await hass.async_block_till_done()
+
+
+async def test_thermostat_available(
+    hass: HomeAssistant, setup_platform: PlatformSetup, create_device: CreateDevice
+):
+    """Test a thermostat that is available."""
+    create_device.create(
+        {
+            "sdm.devices.traits.ThermostatHvac": {
+                "status": "COOLING",
+            },
+            "sdm.devices.traits.ThermostatMode": {
+                "availableModes": ["HEAT", "COOL", "HEATCOOL", "OFF"],
+                "mode": "COOL",
+            },
+            "sdm.devices.traits.Temperature": {
+                "ambientTemperatureCelsius": 29.9,
+            },
+            "sdm.devices.traits.ThermostatTemperatureSetpoint": {
+                "coolCelsius": 28.0,
+            },
+            "sdm.devices.traits.Connectivity": {"status": "ONLINE"},
+        },
+    )
+    await setup_platform()
+
+    assert len(hass.states.async_all()) == 1
+    thermostat = hass.states.get("climate.my_thermostat")
+    assert thermostat is not None
+    assert thermostat.state == HVACMode.COOL
+
+
+async def test_thermostat_unavailable(
+    hass: HomeAssistant, setup_platform: PlatformSetup, create_device: CreateDevice
+):
+    """Test a thermostat that is unavailable."""
+    create_device.create(
+        {
+            "sdm.devices.traits.ThermostatHvac": {
+                "status": "COOLING",
+            },
+            "sdm.devices.traits.ThermostatMode": {
+                "availableModes": ["HEAT", "COOL", "HEATCOOL", "OFF"],
+                "mode": "COOL",
+            },
+            "sdm.devices.traits.Temperature": {
+                "ambientTemperatureCelsius": 29.9,
+            },
+            "sdm.devices.traits.ThermostatTemperatureSetpoint": {
+                "coolCelsius": 28.0,
+            },
+            "sdm.devices.traits.Connectivity": {"status": "OFFLINE"},
+        },
+    )
+    await setup_platform()
+
+    assert len(hass.states.async_all()) == 1
+    thermostat = hass.states.get("climate.my_thermostat")
+    assert thermostat is not None
+    assert thermostat.state == STATE_UNAVAILABLE
diff --git a/tests/components/nest/test_sensor_sdm.py b/tests/components/nest/test_sensor_sdm.py
index d1a89317959d69..c3698cf4123c6b 100644
--- a/tests/components/nest/test_sensor_sdm.py
+++ b/tests/components/nest/test_sensor_sdm.py
@@ -20,6 +20,7 @@
     ATTR_FRIENDLY_NAME,
     ATTR_UNIT_OF_MEASUREMENT,
     PERCENTAGE,
+    STATE_UNAVAILABLE,
     TEMP_CELSIUS,
 )
 from homeassistant.core import HomeAssistant
@@ -90,6 +91,58 @@ async def test_thermostat_device(
     assert device.identifiers == {("nest", DEVICE_ID)}
 
 
+async def test_thermostat_device_available(
+    hass: HomeAssistant, create_device: CreateDevice, setup_platform: PlatformSetup
+):
+    """Test a thermostat with temperature and humidity sensors that is Online."""
+    create_device.create(
+        {
+            "sdm.devices.traits.Temperature": {
+                "ambientTemperatureCelsius": 25.1,
+            },
+            "sdm.devices.traits.Humidity": {
+                "ambientHumidityPercent": 35.0,
+            },
+            "sdm.devices.traits.Connectivity": {"status": "ONLINE"},
+        }
+    )
+    await setup_platform()
+
+    temperature = hass.states.get("sensor.my_sensor_temperature")
+    assert temperature is not None
+    assert temperature.state == "25.1"
+
+    humidity = hass.states.get("sensor.my_sensor_humidity")
+    assert humidity is not None
+    assert humidity.state == "35"
+
+
+async def test_thermostat_device_unavailable(
+    hass: HomeAssistant, create_device: CreateDevice, setup_platform: PlatformSetup
+):
+    """Test a thermostat with temperature and humidity sensors that is Offline."""
+    create_device.create(
+        {
+            "sdm.devices.traits.Temperature": {
+                "ambientTemperatureCelsius": 25.1,
+            },
+            "sdm.devices.traits.Humidity": {
+                "ambientHumidityPercent": 35.0,
+            },
+            "sdm.devices.traits.Connectivity": {"status": "OFFLINE"},
+        }
+    )
+    await setup_platform()
+
+    temperature = hass.states.get("sensor.my_sensor_temperature")
+    assert temperature is not None
+    assert temperature.state == STATE_UNAVAILABLE
+
+    humidity = hass.states.get("sensor.my_sensor_humidity")
+    assert humidity is not None
+    assert humidity.state == STATE_UNAVAILABLE
+
+
 async def test_no_devices(hass: HomeAssistant, setup_platform: PlatformSetup):
     """Test no devices returned by the api."""
     await setup_platform()

Update Climate and Sensor entities to be unavailable when the device connectivity trait indicates the device is offline.

The prior behavior, the last known values would be displayed indefinitely if the device lost internet connectivity.  This was creating the illusion that the device was still connected.  With this change, the Home Assistant entities will become unavailable when the device loses connectivity.

<!--
  You are amazing! Thanks for contributing to our project!
  Please, DO NOT DELETE ANY TEXT from this template! (unless instructed).
-->
## Breaking change
<!--
  If your PR contains a breaking change for existing users, it is important
  to tell them what breaks, how to make it work again and why we did this.
  This piece of text is published with the release notes, so it helps if you
  write it towards our users, not us.
  Note: Remove this section if this PR is NOT a breaking change.
-->


## Proposed change
<!--
  Describe the big picture of your changes here to communicate to the
  maintainers why we should accept this pull request. If it fixes a bug
  or resolves a feature request, be sure to link to that issue in the
  additional information section.
-->


## Type of change
<!--
  What type of change does your PR introduce to Home Assistant?
  NOTE: Please, check only 1! box!
  If your PR requires multiple boxes to be checked, you'll most likely need to
  split it into multiple PRs. This makes things easier and faster to code review.
-->

- [ ] Dependency upgrade
- [x] Bugfix (non-breaking change which fixes an issue)
- [ ] New integration (thank you!)
- [ ] New feature (which adds functionality to an existing integration)
- [ ] Deprecation (breaking change to happen in the future)
- [ ] Breaking change (fix/feature causing existing functionality to break)
- [ ] Code quality improvements to existing code or addition of tests

## Additional information
<!--
  Details are important, and help maintainers processing your PR.
  Please be sure to fill out additional details, if applicable.
-->

- This PR fixes or closes issue: fixes #
- This PR is related to issue: #70479
- Link to documentation pull request: 

## Checklist
<!--
  Put an `x` in the boxes that apply. You can also fill these out after
  creating the PR. If you're unsure about any of them, don't hesitate to ask.
  We're here to help! This is simply a reminder of what we are going to look
  for before merging your code.
-->

- [x] The code change is tested and works locally.
- [x] Local tests pass. **Your PR cannot be merged unless tests pass**
- [x] There is no commented out code in this PR.
- [x] I have followed the [development checklist][dev-checklist]
- [x] The code has been formatted using Black (`black --fast homeassistant tests`)
- [x] Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

- [ ] Documentation added/updated for [www.home-assistant.io][docs-repository]

If the code communicates with devices, web services, or third-party tools:

- [ ] The [manifest file][manifest-docs] has all fields filled out correctly.  
      Updated and included derived files by running: `python3 -m script.hassfest`.
- [ ] New or updated dependencies have been added to `requirements_all.txt`.  
      Updated by running `python3 -m script.gen_requirements_all`.
- [ ] For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
- [ ] Untested files have been added to `.coveragerc`.

The integration reached or maintains the following [Integration Quality Scale][quality-scale]:
<!--
  The Integration Quality Scale scores an integration on the code quality
  and user experience. Each level of the quality scale consists of a list
  of requirements. We highly recommend getting your integration scored!
-->

- [ ] No score or internal
- [ ] 🥈 Silver
- [ ] 🥇 Gold
- [ ] 🏆 Platinum

<!--
  This project is very active and we have a high turnover of pull requests.

  Unfortunately, the number of incoming pull requests is higher than what our
  reviewers can review and merge so there is a long backlog of pull requests
  waiting for review. You can help here!
  
  By reviewing another pull request, you will help raise the code quality of
  that pull request and the final review will be faster. This way the general
  pace of pull request reviews will go up and your wait time will go down.
  
  When picking a pull request to review, try to choose one that hasn't yet
  been reviewed.

  Thanks for helping out!
-->

To help with the load of incoming pull requests:

- [ ] I have reviewed two other [open pull requests][prs] in this repository.

[prs]: https://github.com/home-assistant/core/pulls?q=is%3Aopen+is%3Apr+-author%3A%40me+-draft%3Atrue+-label%3Awaiting-for-upstream+sort%3Acreated-desc+review%3Anone+-status%3Afailure

<!--
  Thank you for contributing <3

  Below, some useful links you could explore:
-->
[dev-checklist]: https://developers.home-assistant.io/docs/en/development_checklist.html
[manifest-docs]: https://developers.home-assistant.io/docs/en/creating_integration_manifest.html
[quality-scale]: https://developers.home-assistant.io/docs/en/next/integration_quality_scale_index.html
[docs-repository]: https://github.com/home-assistant/home-assistant.io
