Skip to content

Home Information - Your home, your data, organized.

Python

Updated simulator to use new CustomUser model.

Anthony Cassandra90ae1c0bd321
diff --git a/src/bin/docker-start-gunicorn.sh b/src/bin/docker-start-gunicorn.sh
index f763680c..15506538 100755
--- a/src/bin/docker-start-gunicorn.sh
+++ b/src/bin/docker-start-gunicorn.sh
@@ -5,7 +5,7 @@
# API polling and processes having inconsistent states.
NUM_WORKERS=1
-NUM_THREADS=3
+NUM_THREADS=9
BINDARG=unix:/var/run/gunicorn.sock
check_redis() {
@@ -30,6 +30,8 @@ check_redis() {
echo "Redis is ready."
}
+check_redis
+
exec gunicorn hi.wsgi:application \
-c /src/bin/docker-gunicorn.conf.py \
--name gunicorn \
@@ -37,17 +39,3 @@ exec gunicorn hi.wsgi:application \
--threads $NUM_THREADS \
--bind=$BINDARG \
--log-file=-
-
-
-# Assuming an I/O bound app and if have machine CPU all to itself
-#NUM_WORKERS=$(( $(nproc) + 1 ))
-#
-#BINDARG=unix:/var/run/gunicorn.sock
-#
-#exec gunicorn hi.asgi:application \
-# -c /src/bin/docker-gunicorn.conf.py \
-# --name gunicorn \
-# --workers $NUM_WORKERS \
-# --worker-class uvicorn.workers.UvicornWorker \
-# --bind=$BINDARG \
-# --log-file=-
diff --git a/src/hi/settings/simulator.py b/src/hi/settings/simulator.py
index 4a8fbf07..84f26092 100644
--- a/src/hi/settings/simulator.py
+++ b/src/hi/settings/simulator.py
@@ -11,6 +11,7 @@ INSTALLED_APPS = [
'pipeline',
'django.contrib.humanize',
+ 'custom',
'hi.apps.common',
'hi.simulator',
'hi.simulator.services.hass',
diff --git a/src/hi/simulator/migrations/0001_initial.py b/src/hi/simulator/migrations/0001_initial.py
new file mode 100644
index 00000000..40c26743
--- /dev/null
+++ b/src/hi/simulator/migrations/0001_initial.py
@@ -0,0 +1,102 @@
+# Generated by Django 4.2.15 on 2025-02-02 16:19
+
+from django.db import migrations, models
+import django.db.models.deletion
+import django.utils.timezone
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = []
+
+ operations = [
+ migrations.CreateModel(
+ name="SimProfile",
+ fields=[
+ (
+ "id",
+ models.BigAutoField(
+ auto_created=True,
+ primary_key=True,
+ serialize=False,
+ verbose_name="ID",
+ ),
+ ),
+ (
+ "name",
+ models.CharField(max_length=128, unique=True, verbose_name="Name"),
+ ),
+ (
+ "last_switched_to_datetime",
+ models.DateTimeField(
+ default=django.utils.timezone.now,
+ verbose_name="Last Switched To",
+ ),
+ ),
+ (
+ "created_datetime",
+ models.DateTimeField(auto_now_add=True, verbose_name="Created"),
+ ),
+ ],
+ options={
+ "verbose_name": "Simulator Profile",
+ "verbose_name_plural": "Simulator Profiles",
+ "ordering": ["-last_switched_to_datetime"],
+ },
+ ),
+ migrations.CreateModel(
+ name="DbSimEntity",
+ fields=[
+ (
+ "id",
+ models.BigAutoField(
+ auto_created=True,
+ primary_key=True,
+ serialize=False,
+ verbose_name="ID",
+ ),
+ ),
+ (
+ "simulator_id",
+ models.CharField(max_length=64, verbose_name="Simulator Id"),
+ ),
+ (
+ "entity_fields_class_id",
+ models.CharField(
+ max_length=255, verbose_name="Entity Fields Class Id"
+ ),
+ ),
+ (
+ "sim_entity_type_str",
+ models.CharField(max_length=32, verbose_name="Entity Type"),
+ ),
+ (
+ "sim_entity_fields_json",
+ models.JSONField(default=dict, verbose_name="Entity Fields"),
+ ),
+ (
+ "created_datetime",
+ models.DateTimeField(auto_now_add=True, verbose_name="Created"),
+ ),
+ (
+ "updated_datetime",
+ models.DateTimeField(auto_now=True, verbose_name="Updated"),
+ ),
+ (
+ "sim_profile",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="db_sim_entities",
+ to="simulator.simprofile",
+ verbose_name="Simulator Profile",
+ ),
+ ),
+ ],
+ options={
+ "verbose_name": "Simulator Entity",
+ "verbose_name_plural": "Simulator Entities",
+ },
+ ),
+ ]