github.com/e154/smart-home@v0.17.2-0.20240311175135-e530a6e5cd45/plugins/uptime/types.go (about) 1 // This file is part of the Smart Home 2 // Program complex distribution https://github.com/e154/smart-home 3 // Copyright (C) 2016-2023, Filippov Alex 4 // 5 // This library is free software: you can redistribute it and/or 6 // modify it under the terms of the GNU Lesser General Public 7 // License as published by the Free Software Foundation; either 8 // version 3 of the License, or (at your option) any later version. 9 // 10 // This library is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 // Library General Public License for more details. 14 // 15 // You should have received a copy of the GNU Lesser General Public 16 // License along with this library. If not, see 17 // <https://www.gnu.org/licenses/>. 18 19 package uptime 20 21 import ( 22 "github.com/e154/smart-home/common" 23 m "github.com/e154/smart-home/models" 24 ) 25 26 const ( 27 // EntitySensor ... 28 EntitySensor = string("uptime") 29 30 // Name ... 31 Name = "uptime" 32 33 Version = "0.0.1" 34 35 AttrUptimeTotal = "uptime_total" 36 AttrAppStarted = "app_started" 37 AttrFirstStart = "first_start" 38 AttrLastShutdown = "last_shutdown" 39 AttrLastShutdownCorrect = "last_shutdown_correct" 40 AttrLastStart = "last_start" 41 AttrUptime = "uptime" 42 AttrDowntime = "downtime" 43 AttrUptimePercent = "uptime_percent" 44 AttrDowntimePercent = "downtime_percent" 45 ) 46 47 // NewAttr ... 48 func NewAttr() m.Attributes { 49 return m.Attributes{ 50 AttrUptimeTotal: { 51 Name: AttrUptimeTotal, 52 Type: common.AttributeInt, 53 }, 54 AttrAppStarted: { 55 Name: AttrAppStarted, 56 Type: common.AttributeTime, 57 }, 58 AttrFirstStart: { 59 Name: AttrFirstStart, 60 Type: common.AttributeTime, 61 }, 62 AttrLastShutdown: { 63 Name: AttrLastShutdown, 64 Type: common.AttributeTime, 65 }, 66 AttrLastShutdownCorrect: { 67 Name: AttrLastShutdownCorrect, 68 Type: common.AttributeBool, 69 }, 70 AttrLastStart: { 71 Name: AttrLastStart, 72 Type: common.AttributeTime, 73 }, 74 AttrUptime: { 75 Name: AttrUptime, 76 Type: common.AttributeInt, 77 }, 78 AttrDowntime: { 79 Name: AttrDowntime, 80 Type: common.AttributeInt, 81 }, 82 AttrUptimePercent: { 83 Name: AttrUptimePercent, 84 Type: common.AttributeFloat, 85 }, 86 AttrDowntimePercent: { 87 Name: AttrDowntimePercent, 88 Type: common.AttributeFloat, 89 }, 90 } 91 }