"""Test Sensors"""
from datetime import timedelta, datetime
from homeassistant.components.sensor import (
    STATE_CLASS_TOTAL_INCREASING,
    DEVICE_CLASS_ENERGY,
)
from homeassistant.core import callback
from homeassistant.const import STATE_UNKNOWN
from .fplEntity import FplEnergyEntity


class TestSensor(FplEnergyEntity):
    """Daily Usage Kwh Sensor"""

    def __init__(self, coordinator, config, account):
        super().__init__(coordinator, config, account, "Test Sensor")

    _attr_state_class = STATE_CLASS_TOTAL_INCREASING
    _attr_device_class = DEVICE_CLASS_ENERGY

    @property
    def native_value(self):
        data = self.getData("daily_usage")

        if data is not None and len(data) > 0 and "usage" in data[-1].keys():
            return data[-1]["usage"]

        return STATE_UNKNOWN

    @property
    def last_reset(self) -> datetime | None:
        last_reset = None
        data = self.getData("daily_usage")
        if len(data) > 0 and "readTime" in data[-1]:
            date = data[-1]["readTime"]
            last_reset = datetime.combine(date, datetime.min.time())
            print(f"setting last reset {last_reset}")
        return last_reset

    def customAttributes(self):
        """Return the state attributes."""
        print("setting custom attributes")
        data = self.getData("daily_usage")
        date = data[-1]["readTime"]

        attributes = {}
        attributes["date"] = date
        last_reset = date - timedelta(days=1)
        # attributes["last_reset"] = last_reset
        return attributes

be469ffc92f017bda6d4e3f7eea0ecc1773bc151
<mask token>


class TestSensor(FplEnergyEntity):
    <mask token>

    def __init__(self, coordinator, config, account):
        super().__init__(coordinator, config, account, 'Test Sensor')
    <mask token>
    <mask token>

    @property
    def native_value(self):
        data = self.getData('daily_usage')
        if data is not None and len(data) > 0 and 'usage' in data[-1].keys():
            return data[-1]['usage']
        return STATE_UNKNOWN

    @property
    def last_reset(self) ->(datetime | None):
        last_reset = None
        data = self.getData('daily_usage')
        if len(data) > 0 and 'readTime' in data[-1]:
            date = data[-1]['readTime']
            last_reset = datetime.combine(date, datetime.min.time())
            print(f'setting last reset {last_reset}')
        return last_reset

    def customAttributes(self):
        """Return the state attributes."""
        print('setting custom attributes')
        data = self.getData('daily_usage')
        date = data[-1]['readTime']
        attributes = {}
        attributes['date'] = date
        last_reset = date - timedelta(days=1)
        return attributes

<mask token>


class TestSensor(FplEnergyEntity):
    <mask token>

    def __init__(self, coordinator, config, account):
        super().__init__(coordinator, config, account, 'Test Sensor')
    _attr_state_class = STATE_CLASS_TOTAL_INCREASING
    _attr_device_class = DEVICE_CLASS_ENERGY

    @property
    def native_value(self):
        data = self.getData('daily_usage')
        if data is not None and len(data) > 0 and 'usage' in data[-1].keys():
            return data[-1]['usage']
        return STATE_UNKNOWN

    @property
    def last_reset(self) ->(datetime | None):
        last_reset = None
        data = self.getData('daily_usage')
        if len(data) > 0 and 'readTime' in data[-1]:
            date = data[-1]['readTime']
            last_reset = datetime.combine(date, datetime.min.time())
            print(f'setting last reset {last_reset}')
        return last_reset

    def customAttributes(self):
        """Return the state attributes."""
        print('setting custom attributes')
        data = self.getData('daily_usage')
        date = data[-1]['readTime']
        attributes = {}
        attributes['date'] = date
        last_reset = date - timedelta(days=1)
        return attributes

<mask token>


class TestSensor(FplEnergyEntity):
    """Daily Usage Kwh Sensor"""

    def __init__(self, coordinator, config, account):
        super().__init__(coordinator, config, account, 'Test Sensor')
    _attr_state_class = STATE_CLASS_TOTAL_INCREASING
    _attr_device_class = DEVICE_CLASS_ENERGY

    @property
    def native_value(self):
        data = self.getData('daily_usage')
        if data is not None and len(data) > 0 and 'usage' in data[-1].keys():
            return data[-1]['usage']
        return STATE_UNKNOWN

    @property
    def last_reset(self) ->(datetime | None):
        last_reset = None
        data = self.getData('daily_usage')
        if len(data) > 0 and 'readTime' in data[-1]:
            date = data[-1]['readTime']
            last_reset = datetime.combine(date, datetime.min.time())
            print(f'setting last reset {last_reset}')
        return last_reset

    def customAttributes(self):
        """Return the state attributes."""
        print('setting custom attributes')
        data = self.getData('daily_usage')
        date = data[-1]['readTime']
        attributes = {}
        attributes['date'] = date
        last_reset = date - timedelta(days=1)
        return attributes

<mask token>
from datetime import timedelta, datetime
from homeassistant.components.sensor import STATE_CLASS_TOTAL_INCREASING, DEVICE_CLASS_ENERGY
from homeassistant.core import callback
from homeassistant.const import STATE_UNKNOWN
from .fplEntity import FplEnergyEntity


class TestSensor(FplEnergyEntity):
    """Daily Usage Kwh Sensor"""

    def __init__(self, coordinator, config, account):
        super().__init__(coordinator, config, account, 'Test Sensor')
    _attr_state_class = STATE_CLASS_TOTAL_INCREASING
    _attr_device_class = DEVICE_CLASS_ENERGY

    @property
    def native_value(self):
        data = self.getData('daily_usage')
        if data is not None and len(data) > 0 and 'usage' in data[-1].keys():
            return data[-1]['usage']
        return STATE_UNKNOWN

    @property
    def last_reset(self) ->(datetime | None):
        last_reset = None
        data = self.getData('daily_usage')
        if len(data) > 0 and 'readTime' in data[-1]:
            date = data[-1]['readTime']
            last_reset = datetime.combine(date, datetime.min.time())
            print(f'setting last reset {last_reset}')
        return last_reset

    def customAttributes(self):
        """Return the state attributes."""
        print('setting custom attributes')
        data = self.getData('daily_usage')
        date = data[-1]['readTime']
        attributes = {}
        attributes['date'] = date
        last_reset = date - timedelta(days=1)
        return attributes

"""Test Sensors"""
from datetime import timedelta, datetime
from homeassistant.components.sensor import (
    STATE_CLASS_TOTAL_INCREASING,
    DEVICE_CLASS_ENERGY,
)
from homeassistant.core import callback
from homeassistant.const import STATE_UNKNOWN
from .fplEntity import FplEnergyEntity


class TestSensor(FplEnergyEntity):
    """Daily Usage Kwh Sensor"""

    def __init__(self, coordinator, config, account):
        super().__init__(coordinator, config, account, "Test Sensor")

    _attr_state_class = STATE_CLASS_TOTAL_INCREASING
    _attr_device_class = DEVICE_CLASS_ENERGY

    @property
    def native_value(self):
        data = self.getData("daily_usage")

        if data is not None and len(data) > 0 and "usage" in data[-1].keys():
            return data[-1]["usage"]

        return STATE_UNKNOWN

    @property
    def last_reset(self) -> datetime | None:
        last_reset = None
        data = self.getData("daily_usage")
        if len(data) > 0 and "readTime" in data[-1]:
            date = data[-1]["readTime"]
            last_reset = datetime.combine(date, datetime.min.time())
            print(f"setting last reset {last_reset}")
        return last_reset

    def customAttributes(self):
        """Return the state attributes."""
        print("setting custom attributes")
        data = self.getData("daily_usage")
        date = data[-1]["readTime"]

        attributes = {}
        attributes["date"] = date
        last_reset = date - timedelta(days=1)
        # attributes["last_reset"] = last_reset
        return attributes
