Release 1.3.0

This commit is contained in:
2021-08-26 12:33:15 +02:00
commit 9bb72f0207
1148 changed files with 92133 additions and 0 deletions

0
dev/vendor/__init__.py vendored Normal file
View File

116
dev/vendor/fake_api_service.js vendored Normal file
View File

@@ -0,0 +1,116 @@
import {Widget} from '@bthlabs/homehub-components';
import {API, BaseService} from '@bthlabs/homehub-core';
import React from 'react';
export const FakeAPIWidgetSettingsView = (props) => {
const onSpamInputChange = React.useCallback(
(event) => {
props.setNextCharacteristics({
...props.nextCharacteristics,
spam: event.target.value
});
},
[props]
);
const onEggsInputChange = React.useCallback(
(event) => {
props.setNextCharacteristics({
...props.nextCharacteristics,
eggs: event.target.value
});
},
[props]
);
if (!props.nextCharacteristics) {
return null;
}
return (
<React.Fragment>
<p>
<label htmlFor="input-spam">Spam</label>
<input
type="text"
value={props.nextCharacteristics.spam}
onChange={onSpamInputChange}
/>
</p>
<p>
<label htmlFor="input-eggs">Eggs</label>
<input
type="text"
value={props.nextCharacteristics.eggs}
onChange={onEggsInputChange}
/>
</p>
</React.Fragment>
)
};
export const FakeAPIWidget = (props) => {
let appearance = {...props.appearance};
if (props.serviceState !== null) {
console.log('FakeAPIWidget()', props.serviceState.payload, props.serviceState.isLoading())
if (props.serviceState.isLoading()) {
appearance.color = 'blue';
} else if (props.serviceState.hasError()) {
appearance.color = 'purple';
} else if (props.serviceState.hasFatalError()) {
appearance.color = 'red';
} else if (props.serviceState.hasData()) {
appearance.color = 'green';
}
}
return (
<Widget {...props} appearance={appearance}>
<p>
<code>spam: &raquo;{props.service.characteristics['spam']}&laquo;</code>
<br/>
<code>eggs: &raquo;{props.service.characteristics['eggs']}&laquo;</code>
</p>
<p>
<code>serviceState: &raquo;{JSON.stringify(props.serviceState)}&laquo;</code>
</p>
</Widget>
);
};
FakeAPIWidget.defaultLayout = {
h: 6,
w: 4
};
FakeAPIWidget.layoutConstraints = {
minH: 6,
minW: 4
};
FakeAPIWidget.settingsView = FakeAPIWidgetSettingsView;
FakeAPIWidget.title = 'Fake API Service';
export class FakeAPIService extends BaseService {
static kind = 'FakeAPIService';
static widget = 'FakeAPIWidget';
static emptyCharacteristics () {
return {
'spam': '',
'eggs': ''
};
}
async start () {
const result = await API.Services.start(
FakeAPIService.kind, this.instance, this.characteristics
);
this.notify(result);
}
async stop () {
return API.Services.stop(FakeAPIService.kind, this.instance);
}
setCharacteristics (newCharacteristics) {
super.setCharacteristics(newCharacteristics);
this.restart()
}
}

33
dev/vendor/fake_api_service.py vendored Normal file
View File

@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
import asyncio
import datetime
import logging
from homehub_backend.lib.services import BaseService, ServiceData
LOGGER = logging.getLogger('homehub.fake_api_service')
class FakeAPIService(BaseService):
KIND = 'FakeAPIService'
def __init__(self, *args, **kwargs):
super(FakeAPIService, self).__init__(*args, **kwargs)
self.started_at = None
async def current_data(self):
result = ServiceData()
if self.started_at:
result.data = {
'started_at': self.started_at.isoformat()
}
return result
async def start(self):
LOGGER.debug('FakeAPIService.start()')
await asyncio.sleep(5)
self.started_at = datetime.datetime.utcnow()
async def stop(self):
LOGGER.debug('FakeAPIService.stop()')

36
dev/vendor/vendor_test.js vendored Normal file
View File

@@ -0,0 +1,36 @@
import {Widget} from '@bthlabs/homehub-components';
import {API, BaseService} from '@bthlabs/homehub-core';
import React from 'react';
export const VendorTestWidget = (props) => {
return (
<Widget {...props}>
<p>Hello, <strong>VendorTestWidget!</strong></p>
</Widget>
);
};
VendorTestWidget.defaultLayout = {
h: 2,
w: 2
};
VendorTestWidget.layoutConstraints = {
minH: 2,
minW: 2
};
VendorTestWidget.title = 'Vendor Test';
export class VendorTestService extends BaseService {
static kind = 'VendorTestService';
static widget = 'VendorTestWidget';
async start () {
const result = await API.Services.start(
VendorTestService.kind, this.instance, this.characteristics
);
this.notify(result.data);
}
async stop () {
return API.Services.stop(VendorTestService.kind, this.instance);
}
}

16
dev/vendor/vendor_test.py vendored Normal file
View File

@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
import logging
from homehub_backend.lib.services import BaseService
LOGGER = logging.getLogger('homehub.vendor_test')
class VendorTestService(BaseService):
KIND = 'VendorTestService'
async def start(self):
LOGGER.debug('VendorTestService.start()')
async def stop(self):
LOGGER.debug('VendorTestService.stop()')