@hashsome/integration.home-assistant 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mock.js ADDED
@@ -0,0 +1,114 @@
1
+ import { MockIntegration, mockLibrary } from '@hashsome/core';
2
+ import { mapEntity } from './mappers/index.js';
3
+ const state = (id, value, attributes = {}) => ({
4
+ entity_id: id,
5
+ state: value,
6
+ attributes,
7
+ last_changed: '2026-01-01T00:00:00.000Z',
8
+ last_updated: '2026-01-01T00:00:00.000Z',
9
+ context: { id: 'mock', parent_id: null, user_id: null },
10
+ });
11
+ /** What Home Assistant reports for a representative home: every domain the mappers understand,
12
+ * and the states a dashboard has to handle (off, unavailable, unknown). Raw states, so the mock
13
+ * is built by the same mapping the real integration uses. */
14
+ const states = () => [
15
+ state('light.plain', 'on', { friendly_name: 'Lamp', supported_color_modes: ['onoff'] }),
16
+ state('light.dimmable', 'on', {
17
+ friendly_name: 'Dimmable light',
18
+ supported_color_modes: ['brightness'],
19
+ brightness: 153,
20
+ }),
21
+ state('light.tunable', 'on', {
22
+ friendly_name: 'Tunable white',
23
+ supported_color_modes: ['color_temp'],
24
+ color_mode: 'color_temp',
25
+ brightness: 255,
26
+ color_temp_kelvin: 2700,
27
+ min_color_temp_kelvin: 2000,
28
+ max_color_temp_kelvin: 6500,
29
+ }),
30
+ state('light.color', 'off', {
31
+ friendly_name: 'Color light',
32
+ supported_color_modes: ['hs'],
33
+ brightness: 255,
34
+ hs_color: [280, 80],
35
+ }),
36
+ state('light.unavailable', 'unavailable', { friendly_name: 'Unplugged light' }),
37
+ state('climate.heater', 'heat', {
38
+ friendly_name: 'Heater',
39
+ hvac_modes: ['off', 'heat'],
40
+ temperature: 21,
41
+ current_temperature: 19.4,
42
+ min_temp: 5,
43
+ max_temp: 30,
44
+ target_temp_step: 0.5,
45
+ }),
46
+ state('climate.thermostat', 'off', {
47
+ friendly_name: 'Thermostat',
48
+ hvac_modes: ['off', 'heat', 'cool', 'auto'],
49
+ temperature: 21.5,
50
+ current_temperature: 18.8,
51
+ preset_modes: ['home', 'away'],
52
+ preset_mode: 'home',
53
+ }),
54
+ state('sensor.temperature', '18.4', {
55
+ friendly_name: 'Temperature',
56
+ device_class: 'temperature',
57
+ unit_of_measurement: '°C',
58
+ }),
59
+ state('sensor.humidity', '52', {
60
+ friendly_name: 'Humidity',
61
+ device_class: 'humidity',
62
+ unit_of_measurement: '%',
63
+ }),
64
+ state('sensor.power', '9', {
65
+ friendly_name: 'Power',
66
+ device_class: 'power',
67
+ unit_of_measurement: 'W',
68
+ }),
69
+ state('sensor.energy', '84.3', {
70
+ friendly_name: 'Energy',
71
+ device_class: 'energy',
72
+ unit_of_measurement: 'kWh',
73
+ }),
74
+ state('sensor.not_reporting', 'unknown', {
75
+ friendly_name: 'Silent sensor',
76
+ device_class: 'temperature',
77
+ }),
78
+ state('binary_sensor.door', 'off', { friendly_name: 'Door', device_class: 'door' }),
79
+ state('person.dan', 'home', { friendly_name: 'Dan' }),
80
+ state('person.alex', 'not_home', { friendly_name: 'Alex' }),
81
+ state('scene.movie_night', 'scening', { friendly_name: 'Movie night' }),
82
+ state('script.shower', 'off', { friendly_name: 'Shower' }),
83
+ state('vacuum.robot', 'docked', { friendly_name: 'Robot vacuum' }),
84
+ state('switch.coffee_maker', 'off', { friendly_name: 'Coffee maker' }),
85
+ state('fan.exhaust', 'off', { friendly_name: 'Exhaust fan' }),
86
+ state('lock.front_door', 'locked', { friendly_name: 'Front door' }),
87
+ state('media_player.living_room', 'playing', {
88
+ friendly_name: 'Living room',
89
+ media_title: 'Blank Space',
90
+ media_artist: 'More More',
91
+ volume_level: 0.4,
92
+ media_position: 64,
93
+ media_duration: 231,
94
+ media_position_updated_at: new Date().toISOString(),
95
+ shuffle: false,
96
+ // play, pause, seek, volume, mute, previous, next, shuffle and browse.
97
+ supported_features: 163967,
98
+ }),
99
+ state('input_boolean.guest_mode', 'off', { friendly_name: 'Guest mode' }),
100
+ ];
101
+ /** A Home Assistant integration that needs no Home Assistant: representative devices, mapped the
102
+ * same way real ones are, and commands that change their state. For tests, the gallery and
103
+ * dashboards under development. */
104
+ export function createMock(options = {}) {
105
+ const entities = {};
106
+ for (const hass of states()) {
107
+ entities[hass.entity_id] = mapEntity(hass, { temperatureUnit: '°C' });
108
+ }
109
+ return new MockIntegration({
110
+ id: options.id ?? 'ha',
111
+ library: mockLibrary(),
112
+ entities: { ...entities, ...options.entities },
113
+ });
114
+ }
package/package.json CHANGED
@@ -1,6 +1,41 @@
1
1
  {
2
2
  "name": "@hashsome/integration.home-assistant",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Home Assistant integration: entities, services, area/entity registry",
5
+ "type": "module",
6
+ "dependencies": {
7
+ "@hashsome/core": "0.1.0",
8
+ "home-assistant-js-websocket": "9.7.0"
9
+ },
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "./mock": {
16
+ "types": "./dist/mock.d.ts",
17
+ "default": "./dist/mock.js"
18
+ },
19
+ "./package.json": "./package.json"
20
+ },
21
+ "license": "GPL-3.0-only",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/dstoyanoff/hashsome.git",
25
+ "directory": "packages/integrations/home-assistant"
26
+ },
27
+ "homepage": "https://github.com/dstoyanoff/hashsome#readme",
28
+ "bugs": "https://github.com/dstoyanoff/hashsome/issues",
29
+ "files": [
30
+ "dist"
31
+ ],
32
+ "publishConfig": {
33
+ "access": "public",
34
+ "provenance": true
35
+ },
36
+ "scripts": {
37
+ "typecheck": "tsc --noEmit",
38
+ "states": "node scripts/print-states.ts",
39
+ "build": "tsc -b tsconfig.build.json"
40
+ }
6
41
  }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.