diff --git a/bundles/org.openhab.binding.sleepiq/README.md b/bundles/org.openhab.binding.sleepiq/README.md index d56c2a618ab..c01f408be61 100644 --- a/bundles/org.openhab.binding.sleepiq/README.md +++ b/bundles/org.openhab.binding.sleepiq/README.md @@ -84,6 +84,10 @@ All channels within this group are read-only, except for the sleepNumber and pri | todayAverageRespirationRate | Number | The average respiration rate for the current day | | todayMessage | String | A description of the sleep quality for the current day | | todaySleepDurationSeconds | Number:Time | The duration of sleep for the current day | +| todaySleepInBedSeconds | Number:Time | The duration of time in bed for the current day | +| todaySleepOutOfBedSeconds | Number:Time | The duration of time out of bed for the current day | +| todaySleepRestfulSeconds | Number:Time | The duration of restful sleep for the current day | +| todaySleepRestlessSeconds | Number:Time | The duration of restless sleep for the current day | | monthlySleepIQ | Number | The average Sleep IQ score for the current month | | monthlyAverageHeartRate | Number | The average heart rate for the current month | | monthlyAverageRespirationRate | Number | The average respiration rate for the current month | @@ -105,8 +109,12 @@ Number MasterBR_SleepIQ_DailySleepIQ_Alice "Daily Sleep IQ [%.0f]" Number MasterBR_SleepIQ_DailyHeartRate_Alice "Daily Heart Rate [%.0f]" { channel="sleepiq:dualBed:1:master:left#todayAverageHeartRate" } Number MasterBR_SleepIQ_DailyRespRate_Alice "Daily Respiration Rate [%.0f]" { channel="sleepiq:dualBed:1:master:left#todayAverageRespirationRate"} String MasterBR_SleepIQ_DailyMessage_Alice "Daily Message [%s]" { channel="sleepiq:dualBed:1:master:left#todayMessage"} -Number MasterBR_SleepIQ_DailyDuration_Alice "Daily Sleep Duration [%.0f]" { channel="sleepiq:dualBed:1:master:left#todaySleepDurationSeconds"} -Number:Time MasterBR_SleepIQ_MonthlySleepIQ_Alice "Monthly Sleep IQ [%d s]" { channel="sleepiq:dualBed:1:master:left#monthlySleepIQ"} +Number:Time MasterBR_SleepIQ_DailyDuration_Alice "Daily Sleep Duration [%.0f]" { channel="sleepiq:dualBed:1:master:left#todaySleepDurationSeconds"} +Number:Time MasterBR_SleepIQ_DailyInBed_Alice "Daily Sleep In Bed [%.0f]" { channel="sleepiq:dualBed:1:master:left#todaySleepInBedSeconds"} +Number:Time MasterBR_SleepIQ_DailyOutOfBed_Alice "Daily Sleep Out Of Bed [%.0f]" { channel="sleepiq:dualBed:1:master:left#todaySleepOutOfBedSeconds"} +Number:Time MasterBR_SleepIQ_DailyRestful_Alice "Daily Sleep Restful [%.0f]" { channel="sleepiq:dualBed:1:master:left#todaySleepRestfulSeconds"} +Number:Time MasterBR_SleepIQ_DailyRestless_Alice "Daily Sleep Restless [%.0f]" { channel="sleepiq:dualBed:1:master:left#todaySleepRestlessSeconds"} +Number MasterBR_SleepIQ_MonthlySleepIQ_Alice "Monthly Sleep IQ [%d s]" { channel="sleepiq:dualBed:1:master:left#monthlySleepIQ"} Number MasterBR_SleepIQ_MonthlyHeartRate_Alice "Monthly Heart Rate [%.0f]" { channel="sleepiq:dualBed:1:master:left#monthlyAverageHeartRate"} Number MasterBR_SleepIQ_MonthlyRespRate_Alice "Monthly Respiration Rate [%.0f]" { channel="sleepiq:dualBed:1:master:left#monthlyAverageRespirationRate"} @@ -124,6 +132,10 @@ Number MasterBR_SleepIQ_DailyHeartRate_Bob "Daily Heart Rate [%.0f]" Number MasterBR_SleepIQ_DailyRespRate_Bob "Daily Respiration Rate [%.0f]" { channel="sleepiq:dualBed:1:master:right#todayAverageRespirationRate"} String MasterBR_SleepIQ_DailyMessage_Bob "Daily Message [%s]" { channel="sleepiq:dualBed:1:master:right#todayMessage"} Number:Time MasterBR_SleepIQ_DailyDuration_Bob "Daily Sleep Duration [%d s]" { channel="sleepiq:dualBed:1:master:right#todaySleepDurationSeconds"} +Number:Time MasterBR_SleepIQ_DailyInBed_Bob "Daily Sleep In Bed [%.0f]" { channel="sleepiq:dualBed:1:master:right#todaySleepInBedSeconds"} +Number:Time MasterBR_SleepIQ_DailyOutOfBed_Bob "Daily Sleep Out Of Bed [%.0f]" { channel="sleepiq:dualBed:1:master:right#todaySleepOutOfBedSeconds"} +Number:Time MasterBR_SleepIQ_DailyRestful_Bob "Daily Sleep Restful [%.0f]" { channel="sleepiq:dualBed:1:master:right#todaySleepRestfulSeconds"} +Number:Time MasterBR_SleepIQ_DailyRestless_Bob "Daily Sleep Restless [%.0f]" { channel="sleepiq:dualBed:1:master:right#todaySleepRestlessSeconds"} Number MasterBR_SleepIQ_MonthlySleepIQ_Bob "Monthly Sleep IQ [%.0f]" { channel="sleepiq:dualBed:1:master:right#monthlySleepIQ"} Number MasterBR_SleepIQ_MonthlyHeartRate_Bob "Monthly Heart Rate [%.0f]" { channel="sleepiq:dualBed:1:master:right#monthlyAverageHeartRate"} Number MasterBR_SleepIQ_MonthlyRespRate_Bob "Monthly Respiration Rate [%.0f]" { channel="sleepiq:dualBed:1:master:right#monthlyAverageRespirationRate"} diff --git a/bundles/org.openhab.binding.sleepiq/src/main/java/org/openhab/binding/sleepiq/internal/SleepIQBindingConstants.java b/bundles/org.openhab.binding.sleepiq/src/main/java/org/openhab/binding/sleepiq/internal/SleepIQBindingConstants.java index 63023921adc..dc1191c97ce 100644 --- a/bundles/org.openhab.binding.sleepiq/src/main/java/org/openhab/binding/sleepiq/internal/SleepIQBindingConstants.java +++ b/bundles/org.openhab.binding.sleepiq/src/main/java/org/openhab/binding/sleepiq/internal/SleepIQBindingConstants.java @@ -76,6 +76,18 @@ public class SleepIQBindingConstants { public static final String CHANNEL_LEFT_TODAY_SLEEP_DURATION_SECONDS = "left#todaySleepDurationSeconds"; public static final String CHANNEL_RIGHT_TODAY_SLEEP_DURATION_SECONDS = "right#todaySleepDurationSeconds"; + public static final String CHANNEL_LEFT_TODAY_SLEEP_IN_BED_SECONDS = "left#todaySleepInBedSeconds"; + public static final String CHANNEL_RIGHT_TODAY_SLEEP_IN_BED_SECONDS = "right#todaySleepInBedSeconds"; + + public static final String CHANNEL_LEFT_TODAY_SLEEP_OUT_OF_BED_SECONDS = "left#todaySleepOutOfBedSeconds"; + public static final String CHANNEL_RIGHT_TODAY_SLEEP_OUT_OF_BED_SECONDS = "right#todaySleepOutOfBedSeconds"; + + public static final String CHANNEL_LEFT_TODAY_SLEEP_RESTFUL_SECONDS = "left#todaySleepRestfulSeconds"; + public static final String CHANNEL_RIGHT_TODAY_SLEEP_RESTFUL_SECONDS = "right#todaySleepRestfulSeconds"; + + public static final String CHANNEL_LEFT_TODAY_SLEEP_RESTLESS_SECONDS = "left#todaySleepRestlessSeconds"; + public static final String CHANNEL_RIGHT_TODAY_SLEEP_RESTLESS_SECONDS = "right#todaySleepRestlessSeconds"; + public static final String CHANNEL_LEFT_MONTHLY_SLEEP_IQ = "left#monthlySleepIQ"; public static final String CHANNEL_RIGHT_MONTHLY_SLEEP_IQ = "right#monthlySleepIQ"; diff --git a/bundles/org.openhab.binding.sleepiq/src/main/java/org/openhab/binding/sleepiq/internal/handler/SleepIQDualBedHandler.java b/bundles/org.openhab.binding.sleepiq/src/main/java/org/openhab/binding/sleepiq/internal/handler/SleepIQDualBedHandler.java index b20b6884f08..e353aa58896 100644 --- a/bundles/org.openhab.binding.sleepiq/src/main/java/org/openhab/binding/sleepiq/internal/handler/SleepIQDualBedHandler.java +++ b/bundles/org.openhab.binding.sleepiq/src/main/java/org/openhab/binding/sleepiq/internal/handler/SleepIQDualBedHandler.java @@ -242,12 +242,20 @@ public class SleepIQDualBedHandler extends BaseThingHandler implements BedStatus updateState(CHANNEL_LEFT_TODAY_AVG_RESPIRATION_RATE, UnDefType.UNDEF); updateState(CHANNEL_LEFT_TODAY_MESSAGE, UnDefType.UNDEF); updateState(CHANNEL_LEFT_TODAY_SLEEP_DURATION_SECONDS, UnDefType.UNDEF); + updateState(CHANNEL_LEFT_TODAY_SLEEP_IN_BED_SECONDS, UnDefType.UNDEF); + updateState(CHANNEL_LEFT_TODAY_SLEEP_OUT_OF_BED_SECONDS, UnDefType.UNDEF); + updateState(CHANNEL_LEFT_TODAY_SLEEP_RESTFUL_SECONDS, UnDefType.UNDEF); + updateState(CHANNEL_LEFT_TODAY_SLEEP_RESTLESS_SECONDS, UnDefType.UNDEF); } else { updateState(CHANNEL_RIGHT_TODAY_SLEEP_IQ, UnDefType.UNDEF); updateState(CHANNEL_RIGHT_TODAY_AVG_HEART_RATE, UnDefType.UNDEF); updateState(CHANNEL_RIGHT_TODAY_AVG_RESPIRATION_RATE, UnDefType.UNDEF); updateState(CHANNEL_RIGHT_TODAY_MESSAGE, UnDefType.UNDEF); updateState(CHANNEL_RIGHT_TODAY_SLEEP_DURATION_SECONDS, UnDefType.UNDEF); + updateState(CHANNEL_RIGHT_TODAY_SLEEP_IN_BED_SECONDS, UnDefType.UNDEF); + updateState(CHANNEL_RIGHT_TODAY_SLEEP_OUT_OF_BED_SECONDS, UnDefType.UNDEF); + updateState(CHANNEL_RIGHT_TODAY_SLEEP_RESTFUL_SECONDS, UnDefType.UNDEF); + updateState(CHANNEL_RIGHT_TODAY_SLEEP_RESTLESS_SECONDS, UnDefType.UNDEF); } return; } else if (sleeper.getSide().equals(Side.LEFT)) { @@ -258,6 +266,14 @@ public class SleepIQDualBedHandler extends BaseThingHandler implements BedStatus updateState(CHANNEL_LEFT_TODAY_MESSAGE, new StringType(sleepData.getSleepDataDays().get(0).getMessage())); updateState(CHANNEL_LEFT_TODAY_SLEEP_DURATION_SECONDS, new QuantityType<>(sleepData.getTotalSleepSessionTime(), Units.SECOND)); + updateState(CHANNEL_LEFT_TODAY_SLEEP_IN_BED_SECONDS, + new QuantityType<>(sleepData.getTotalInBedSeconds(), Units.SECOND)); + updateState(CHANNEL_LEFT_TODAY_SLEEP_OUT_OF_BED_SECONDS, + new QuantityType<>(sleepData.getTotalOutOfBedSeconds(), Units.SECOND)); + updateState(CHANNEL_LEFT_TODAY_SLEEP_RESTFUL_SECONDS, + new QuantityType<>(sleepData.getTotalRestfulSeconds(), Units.SECOND)); + updateState(CHANNEL_LEFT_TODAY_SLEEP_RESTLESS_SECONDS, + new QuantityType<>(sleepData.getTotalRestlessSeconds(), Units.SECOND)); } else if (sleeper.getSide().equals(Side.RIGHT)) { updateState(CHANNEL_RIGHT_TODAY_SLEEP_IQ, new DecimalType(sleepData.getAverageSleepIQ())); updateState(CHANNEL_RIGHT_TODAY_AVG_HEART_RATE, new DecimalType(sleepData.getAverageHeartRate())); @@ -266,6 +282,14 @@ public class SleepIQDualBedHandler extends BaseThingHandler implements BedStatus updateState(CHANNEL_RIGHT_TODAY_MESSAGE, new StringType(sleepData.getSleepDataDays().get(0).getMessage())); updateState(CHANNEL_RIGHT_TODAY_SLEEP_DURATION_SECONDS, new QuantityType<>(sleepData.getTotalSleepSessionTime(), Units.SECOND)); + updateState(CHANNEL_RIGHT_TODAY_SLEEP_IN_BED_SECONDS, + new QuantityType<>(sleepData.getTotalInBedSeconds(), Units.SECOND)); + updateState(CHANNEL_RIGHT_TODAY_SLEEP_OUT_OF_BED_SECONDS, + new QuantityType<>(sleepData.getTotalOutOfBedSeconds(), Units.SECOND)); + updateState(CHANNEL_RIGHT_TODAY_SLEEP_RESTFUL_SECONDS, + new QuantityType<>(sleepData.getTotalRestfulSeconds(), Units.SECOND)); + updateState(CHANNEL_RIGHT_TODAY_SLEEP_RESTLESS_SECONDS, + new QuantityType<>(sleepData.getTotalRestlessSeconds(), Units.SECOND)); } } diff --git a/bundles/org.openhab.binding.sleepiq/src/main/resources/OH-INF/i18n/sleepiq.properties b/bundles/org.openhab.binding.sleepiq/src/main/resources/OH-INF/i18n/sleepiq.properties index b845d01c898..0e1bff9e3bc 100644 --- a/bundles/org.openhab.binding.sleepiq/src/main/resources/OH-INF/i18n/sleepiq.properties +++ b/bundles/org.openhab.binding.sleepiq/src/main/resources/OH-INF/i18n/sleepiq.properties @@ -1,3 +1,76 @@ +# add-on + +addon.sleepiq.name = SleepIQ Binding +addon.sleepiq.description = This is the binding for the Sleep Number SleepIQ system. + +# thing types + +thing-type.sleepiq.cloud.label = SleepIQ Cloud +thing-type.sleepiq.cloud.description = The SleepIQ cloud service provides connections to all beds in an account. +thing-type.sleepiq.dualBed.label = Dual Chamber Bed +thing-type.sleepiq.dualBed.description = A Sleep Number bed with SleepIQ and two individual air chambers + +# thing types config + +thing-type.config.sleepiq.cloud.password.label = Password +thing-type.config.sleepiq.cloud.password.description = Password of a registered SleepIQ account owner +thing-type.config.sleepiq.cloud.pollingInterval.label = Polling Interval +thing-type.config.sleepiq.cloud.pollingInterval.description = Seconds between fetching values from the cloud service +thing-type.config.sleepiq.cloud.username.label = Username +thing-type.config.sleepiq.cloud.username.description = Username of a registered SleepIQ account owner +thing-type.config.sleepiq.dualBed.bedId.label = Bed ID +thing-type.config.sleepiq.dualBed.bedId.description = The bed identifier identifies a specific bed + +# channel group types + +channel-group-type.sleepiq.chamberGroupType.label = Chamber + +# channel types + +channel-type.sleepiq.alertDetailedMessageType.label = Alert Detailed Message +channel-type.sleepiq.alertDetailedMessageType.description = A detailed message describing an alert condition with the chamber +channel-type.sleepiq.alertIdType.label = Alert ID +channel-type.sleepiq.alertIdType.description = Identifier for an alert condition with the chamber +channel-type.sleepiq.firstNameType.label = First Name +channel-type.sleepiq.firstNameType.description = The first name of the sleeper +channel-type.sleepiq.inBedType.label = In Bed +channel-type.sleepiq.inBedType.description = The presence of a person or object on the chamber +channel-type.sleepiq.lastLinkType.label = Last Link +channel-type.sleepiq.lastLinkType.description = The amount of time that has passed since a connection was made from the chamber to the cloud service (D d HH:MM:SS) +channel-type.sleepiq.monthlyAverageHeartRateType.label = Monthly Avg Heart Rate +channel-type.sleepiq.monthlyAverageHeartRateType.description = The average heart rate for the past month +channel-type.sleepiq.monthlyAverageRespirationRateType.label = Monthly Avg Respiration Rate +channel-type.sleepiq.monthlyAverageRespirationRateType.description = The average respiration rate for the past month +channel-type.sleepiq.monthlySleepIQType.label = Monthly Sleep IQ +channel-type.sleepiq.monthlySleepIQType.description = The overall Sleep Quotient for the past month +channel-type.sleepiq.pressureType.label = Pressure +channel-type.sleepiq.pressureType.description = The current pressure inside the chamber +channel-type.sleepiq.privacyMode.label = Privacy Mode +channel-type.sleepiq.privacyMode.description = Enable/disable privacy mode +channel-type.sleepiq.sleepGoalMinutesType.label = Sleep Goal +channel-type.sleepiq.sleepGoalMinutesType.description = The goal for the amount of sleep per night (in minutes) +channel-type.sleepiq.sleepNumberType.label = Sleep Number +channel-type.sleepiq.sleepNumberType.description = The Sleep Number setting of the chamber +channel-type.sleepiq.todayAverageHeartRateType.label = Today's Avg Heart Rate +channel-type.sleepiq.todayAverageHeartRateType.description = The average heart rate for today +channel-type.sleepiq.todayAverageRespirationRateType.label = Today's Avg Respiration Rate +channel-type.sleepiq.todayAverageRespirationRateType.description = The average respiration rate for today +channel-type.sleepiq.todayMessageType.label = Today's Message +channel-type.sleepiq.todayMessageType.description = The description of today's sleep quality +channel-type.sleepiq.todaySleepDurationSecondsType.label = Today's Sleep Duration +channel-type.sleepiq.todaySleepDurationSecondsType.description = The total duration of sleep for today in seconds +channel-type.sleepiq.todaySleepIQType.label = Today's Sleep IQ +channel-type.sleepiq.todaySleepIQType.description = The Sleep Quotient for today +channel-type.sleepiq.todaySleepInBedSecondsType.label = Today's Sleep In Bed Duration +channel-type.sleepiq.todaySleepInBedSecondsType.description = The total duration of time in bed in seconds +channel-type.sleepiq.todaySleepOutOfBedSecondsType.label = Today's Sleep Out Of Bed Duration +channel-type.sleepiq.todaySleepOutOfBedSecondsType.description = The total duration of time out of bed in seconds +channel-type.sleepiq.todaySleepRestfulSecondsType.label = Today's Sleep Restful Duration +channel-type.sleepiq.todaySleepRestfulSecondsType.description = The total duration of restful sleep for today in seconds +channel-type.sleepiq.todaySleepRestlessSecondsType.label = Today's Sleep Restless Duration +channel-type.sleepiq.todaySleepRestlessSecondsType.description = The total duration of restless sleep for today in seconds + # configuration messages -config-status.error.missing-username-configuration=No username for the SleepIQ cloud has been provided. -config-status.error.missing-password-configuration=No password for the SleepIQ cloud has been provided. + +config-status.error.missing-username-configuration = No username for the SleepIQ cloud has been provided. +config-status.error.missing-password-configuration = No password for the SleepIQ cloud has been provided. diff --git a/bundles/org.openhab.binding.sleepiq/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.sleepiq/src/main/resources/OH-INF/thing/thing-types.xml index 2c91eac6301..0c8c60a388b 100644 --- a/bundles/org.openhab.binding.sleepiq/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.sleepiq/src/main/resources/OH-INF/thing/thing-types.xml @@ -18,12 +18,12 @@ Username of a registered SleepIQ account owner - + Password of a registered SleepIQ account owner password - + Seconds between fetching values from the cloud service 120 @@ -94,6 +94,10 @@ + + + + @@ -185,6 +189,30 @@ The total duration of sleep for today in seconds + + Number:Time + + The total duration of time in bed in seconds + + + + Number:Time + + The total duration of time out of bed in seconds + + + + Number:Time + + The total duration of restful sleep for today in seconds + + + + Number:Time + + The total duration of restless sleep for today in seconds + + Number