]> git.basschouten.com Git - openhab-addons.git/commitdiff
[sleepiq] Add new channels (#14447)
authorMark Hilbush <mark@hilbush.com>
Sun, 19 Feb 2023 21:53:35 +0000 (16:53 -0500)
committerGitHub <noreply@github.com>
Sun, 19 Feb 2023 21:53:35 +0000 (22:53 +0100)
Signed-off-by: Mark Hilbush <mark@hilbush.com>
bundles/org.openhab.binding.sleepiq/README.md
bundles/org.openhab.binding.sleepiq/src/main/java/org/openhab/binding/sleepiq/internal/SleepIQBindingConstants.java
bundles/org.openhab.binding.sleepiq/src/main/java/org/openhab/binding/sleepiq/internal/handler/SleepIQDualBedHandler.java
bundles/org.openhab.binding.sleepiq/src/main/resources/OH-INF/i18n/sleepiq.properties
bundles/org.openhab.binding.sleepiq/src/main/resources/OH-INF/thing/thing-types.xml

index d56c2a618abdd7cdc5fe1f45e23757efb6c9217d..c01f408be61d48261a3febbe7db3466c76b95c1e 100644 (file)
@@ -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"}
index 63023921adc26df9dd5827f15ce5c496bcb2a0ff..dc1191c97cef31eb830ec3ea9acc078687b911d0 100644 (file)
@@ -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";
 
index b20b6884f086581bc6cf1d49e83774187034cfd0..e353aa58896c1894a07143818017d0f1ee1a8a20 100644 (file)
@@ -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));
         }
     }
 
index b845d01c8987ef12319ed99c57266c836119a386..0e1bff9e3bc676288c5bb2afce10c464920af521 100644 (file)
@@ -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.
index 2c91eac6301a2e1f1607c91dbbf6d78ecec60eef..0c8c60a388b63cda04ca590d4609f4c67a2af874 100644 (file)
                                <label>Username</label>
                                <description>Username of a registered SleepIQ account owner</description>
                        </parameter>
-                       <parameter name="password" type="text" required="false">
+                       <parameter name="password" type="text" required="true">
                                <label>Password</label>
                                <description>Password of a registered SleepIQ account owner</description>
                                <context>password</context>
                        </parameter>
-                       <parameter name="pollingInterval" type="integer" min="30" step="30" required="true">
+                       <parameter name="pollingInterval" type="integer" min="30" step="30">
                                <label>Polling Interval</label>
                                <description>Seconds between fetching values from the cloud service</description>
                                <default>120</default>
                        <channel id="todayAverageRespirationRate" typeId="todayAverageRespirationRateType"/>
                        <channel id="todayMessage" typeId="todayMessageType"/>
                        <channel id="todaySleepDurationSeconds" typeId="todaySleepDurationSecondsType"/>
+                       <channel id="todaySleepInBedSeconds" typeId="todaySleepInBedSecondsType"/>
+                       <channel id="todaySleepOutOfBedSeconds" typeId="todaySleepOutOfBedSecondsType"/>
+                       <channel id="todaySleepRestfulSeconds" typeId="todaySleepRestfulSecondsType"/>
+                       <channel id="todaySleepRestlessSeconds" typeId="todaySleepRestlessSecondsType"/>
                        <channel id="monthlySleepIQ" typeId="monthlySleepIQType"/>
                        <channel id="monthlyAverageHeartRate" typeId="monthlyAverageHeartRateType"/>
                        <channel id="monthlyAverageRespirationRate" typeId="monthlyAverageRespirationRateType"/>
                <description>The total duration of sleep for today in seconds</description>
                <state readOnly="true" pattern="%d %unit%"/>
        </channel-type>
+       <channel-type id="todaySleepInBedSecondsType">
+               <item-type>Number:Time</item-type>
+               <label>Today's Sleep In Bed Duration</label>
+               <description>The total duration of time in bed in seconds</description>
+               <state readOnly="true" pattern="%d %unit%"/>
+       </channel-type>
+       <channel-type id="todaySleepOutOfBedSecondsType">
+               <item-type>Number:Time</item-type>
+               <label>Today's Sleep Out Of Bed Duration</label>
+               <description>The total duration of time out of bed in seconds</description>
+               <state readOnly="true" pattern="%d %unit%"/>
+       </channel-type>
+       <channel-type id="todaySleepRestfulSecondsType">
+               <item-type>Number:Time</item-type>
+               <label>Today's Sleep Restful Duration</label>
+               <description>The total duration of restful sleep for today in seconds</description>
+               <state readOnly="true" pattern="%d %unit%"/>
+       </channel-type>
+       <channel-type id="todaySleepRestlessSecondsType">
+               <item-type>Number:Time</item-type>
+               <label>Today's Sleep Restless Duration</label>
+               <description>The total duration of restless sleep for today in seconds</description>
+               <state readOnly="true" pattern="%d %unit%"/>
+       </channel-type>
        <channel-type id="monthlySleepIQType">
                <item-type>Number</item-type>
                <label>Monthly Sleep IQ</label>