Skip to content

Commit

Permalink
remove switch support
Browse files Browse the repository at this point in the history
  • Loading branch information
ljmerza committed Dec 1, 2023
1 parent 2b47985 commit 34aa404
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 32 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ entity: remote.harmony_hub
| ---- | ---- | ------- | -----------
| type | string | **Required** | `custom:harmony-remote-card`
| entity | string | **Required** | `remote.harmony_hub` the name of the harmony hub entity
| activityEntity | string | **Optional** | `select.harmony_hub_activities` the name of the harmony hub activities select entity. Required to set activities.
| devices | Array | **Optional** | a list of devices to add custom commands to. See below for more info.
| activities | Array | **Optional** | a list of activities. Note this will override the default activities shown
| vibrate | Boolean | **Optional** | `true` vibrate on button push
Expand Down
32 changes: 16 additions & 16 deletions dist/harmony-remote-card.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/harmony-remote-card.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "harmony-remote-card",
"version": "1.7.3",
"version": "2.0.0",
"description": "A Logitech harmony remote card for Home Assistant Lovelace UI",
"keywords": [
"home-assistant",
Expand Down
1 change: 1 addition & 0 deletions src/defaults.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export default {
entity: "",
activityEntity: "",
devices: [],
activities: [],
vibrate: true,
Expand Down
31 changes: 17 additions & 14 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ class HarmonyRemoteCard extends LitElement {

const uiList = configActivities.length ? configActivities: activityList;

const entityName = this.config.activityEntity;
const selectEntity = this.hass.states[entityName];

return html`
<div class="activities">
<button
Expand All @@ -79,7 +82,7 @@ class HarmonyRemoteCard extends LitElement {
Off
</button>
${uiList.map((item) => {
${selectEntity && uiList.map((item) => {
// if using custom config then set those props
if(configActivities.length){
// check if custom name exists
Expand All @@ -91,19 +94,18 @@ class HarmonyRemoteCard extends LitElement {
const activityName = item.name || item.activity || item;
const activity = item.activity || item;
const isActive = selectEntity.state === activityName;
const entityName = item.entity || `switch.${prename}_${activity
.replace(/ /g, "_")
.toLowerCase()}`;
const entity = this.hass.states[entityName];
const isActive = entity && entity.state === "on";
const onClick = () =>
const onClick = () => {
console.log('vlick')
this.callService({
service: "turn_on",
data: { activity },
entityId: selectEntity.entity_id,
domain: 'select',
service: "select_option",
data: { option: activity },
});
}
return html`
<button
Expand Down Expand Up @@ -259,20 +261,21 @@ class HarmonyRemoteCard extends LitElement {
}
}

commandService({ service = "send_command", command }) {
commandService({ domain = "remote", service = "send_command", command }) {
const activeDevice = this.getActiveDevice();

this.callService({
domain,
service,
data: { command, device: activeDevice },
});
}

callService({ domain = "remote", service = "", data }) {
callService({ domain = "remote", service = "", entityId, data }) {
this.vibrate();

this.hass.callService(domain, service, {
entity_id: this.config.entity,
entity_id: entityId || this.config.entity,
...data,
});
}
Expand Down

0 comments on commit 34aa404

Please sign in to comment.