mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 07:02:02 +01:00
[amplipi] Add new power channel to zones and groups (#16171)
* [amplipi] Add new power channel to zones and groups Signed-off-by: Kai Kreuzer <kai@openhab.org>
This commit is contained in:
parent
8a0361feb6
commit
f079d1d662
@ -40,6 +40,7 @@ The `zone` and `group` Things have the following channels:
|
||||
|
||||
| Channel | Type | Description |
|
||||
|----------|--------|----------------------------------------------------|
|
||||
| power | Switch | Whether the zone/group is active or off |
|
||||
| volume | Dimmer | The volume of the zone/group |
|
||||
| mute | Switch | Mutes the zone/group |
|
||||
| source | Number | The source (1-4) that this zone/group is playing |
|
||||
@ -70,6 +71,7 @@ String Input2 "Input 2" { channel="amplipi:controller:1:
|
||||
String Input3 "Input 3" { channel="amplipi:controller:1:input3" }
|
||||
String Input4 "Input 4" { channel="amplipi:controller:1:input4" }
|
||||
|
||||
Switch PowerZ2 "Power Zone2" { channel="amplipi:zone:1:zone2:power" }
|
||||
Dimmer VolumeZ2 "Volume Zone2" { channel="amplipi:zone:1:zone2:volume" }
|
||||
Switch MuteZ2 "Mute Zone2" { channel="amplipi:zone:1:zone2::mute" }
|
||||
Number SourceZ2 "Source Zone2" { channel="amplipi:zone:1:zone2::source" }
|
||||
@ -88,6 +90,7 @@ sitemap amplipi label="Main Menu"
|
||||
Selection item=Input4
|
||||
}
|
||||
Frame label="Living Room Zone" {
|
||||
Switch item=PowerZ2
|
||||
Slider item=VolumeZ2 label="Volume Zone 1 [%.1f %%]"
|
||||
Switch item=MuteZ2
|
||||
Selection item=SourceZ2
|
||||
|
@ -34,6 +34,7 @@ public class AmpliPiBindingConstants {
|
||||
// List of all Channel ids
|
||||
public static final String CHANNEL_PRESET = "preset";
|
||||
public static final String CHANNEL_INPUT = "input";
|
||||
public static final String CHANNEL_POWER = "power";
|
||||
public static final String CHANNEL_VOLUME = "volume";
|
||||
public static final String CHANNEL_MUTE = "mute";
|
||||
public static final String CHANNEL_SOURCE = "source";
|
||||
|
@ -103,6 +103,11 @@ public class AmpliPiGroupHandler extends BaseThingHandler implements AmpliPiStat
|
||||
}
|
||||
GroupUpdate update = new GroupUpdate();
|
||||
switch (channelUID.getId()) {
|
||||
case AmpliPiBindingConstants.CHANNEL_POWER:
|
||||
if (command instanceof OnOffType) {
|
||||
update.setMute(command == OnOffType.OFF);
|
||||
}
|
||||
break;
|
||||
case AmpliPiBindingConstants.CHANNEL_MUTE:
|
||||
if (command instanceof OnOffType) {
|
||||
update.setMute(command == OnOffType.ON);
|
||||
@ -159,10 +164,12 @@ public class AmpliPiGroupHandler extends BaseThingHandler implements AmpliPiStat
|
||||
private void updateGroupState(Group state) {
|
||||
this.groupState = state;
|
||||
|
||||
Boolean power = !groupState.getMute();
|
||||
Boolean mute = groupState.getMute();
|
||||
Integer volDelta = groupState.getVolDelta();
|
||||
Integer sourceId = groupState.getSourceId();
|
||||
|
||||
updateState(AmpliPiBindingConstants.CHANNEL_POWER, OnOffType.from(power));
|
||||
updateState(AmpliPiBindingConstants.CHANNEL_MUTE, OnOffType.from(mute));
|
||||
updateState(AmpliPiBindingConstants.CHANNEL_VOLUME, AmpliPiUtils.volumeToPercentType(volDelta));
|
||||
updateState(AmpliPiBindingConstants.CHANNEL_SOURCE, new DecimalType(sourceId));
|
||||
|
@ -103,6 +103,11 @@ public class AmpliPiZoneHandler extends BaseThingHandler implements AmpliPiStatu
|
||||
}
|
||||
ZoneUpdate update = new ZoneUpdate();
|
||||
switch (channelUID.getId()) {
|
||||
case AmpliPiBindingConstants.CHANNEL_POWER:
|
||||
if (command instanceof OnOffType) {
|
||||
update.setMute(command == OnOffType.OFF);
|
||||
}
|
||||
break;
|
||||
case AmpliPiBindingConstants.CHANNEL_MUTE:
|
||||
if (command instanceof OnOffType) {
|
||||
update.setMute(command == OnOffType.ON);
|
||||
@ -159,10 +164,12 @@ public class AmpliPiZoneHandler extends BaseThingHandler implements AmpliPiStatu
|
||||
private void updateZoneState(Zone state) {
|
||||
this.zoneState = state;
|
||||
|
||||
Boolean power = !zoneState.getMute();
|
||||
Boolean mute = zoneState.getMute();
|
||||
Integer vol = zoneState.getVol();
|
||||
Integer sourceId = zoneState.getSourceId();
|
||||
|
||||
updateState(AmpliPiBindingConstants.CHANNEL_POWER, OnOffType.from(power));
|
||||
updateState(AmpliPiBindingConstants.CHANNEL_MUTE, OnOffType.from(mute));
|
||||
updateState(AmpliPiBindingConstants.CHANNEL_VOLUME, AmpliPiUtils.volumeToPercentType(vol));
|
||||
updateState(AmpliPiBindingConstants.CHANNEL_SOURCE, new DecimalType(sourceId));
|
||||
|
@ -51,11 +51,16 @@
|
||||
<description>A zone of the AmpliPi system</description>
|
||||
|
||||
<channels>
|
||||
<channel typeId="system.power" id="power"/>
|
||||
<channel typeId="system.volume" id="volume"/>
|
||||
<channel typeId="system.mute" id="mute"/>
|
||||
<channel typeId="source" id="source"/>
|
||||
</channels>
|
||||
|
||||
<properties>
|
||||
<property name="thingTypeVersion">1</property>
|
||||
</properties>
|
||||
|
||||
<config-description>
|
||||
<parameter name="id" type="integer" required="true">
|
||||
<label>Zone ID</label>
|
||||
@ -79,11 +84,16 @@
|
||||
<description>A group of the AmpliPi system</description>
|
||||
|
||||
<channels>
|
||||
<channel typeId="system.power" id="power"/>
|
||||
<channel typeId="system.volume" id="volume"/>
|
||||
<channel typeId="system.mute" id="mute"/>
|
||||
<channel typeId="source" id="source"/>
|
||||
</channels>
|
||||
|
||||
<properties>
|
||||
<property name="thingTypeVersion">1</property>
|
||||
</properties>
|
||||
|
||||
<config-description>
|
||||
<parameter name="id" type="integer" required="true">
|
||||
<label>Group ID</label>
|
||||
|
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<update:update-descriptions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:update="https://openhab.org/schemas/update-description/v1.0.0"
|
||||
xsi:schemaLocation="https://openhab.org/schemas/update-description/v1.0.0 https://openhab.org/schemas/update-description-1.0.0.xsd">
|
||||
<thing-type uid="amplipi:zone">
|
||||
<instruction-set targetVersion="1">
|
||||
<add-channel id="power">
|
||||
<type>system:power</type>
|
||||
</add-channel>
|
||||
</instruction-set>
|
||||
</thing-type>
|
||||
<thing-type uid="amplipi:group">
|
||||
<instruction-set targetVersion="1">
|
||||
<add-channel id="power">
|
||||
<type>system:power</type>
|
||||
</add-channel>
|
||||
</instruction-set>
|
||||
</thing-type>
|
||||
</update:update-descriptions>
|
Loading…
Reference in New Issue
Block a user